Created
March 27, 2017 01:46
-
-
Save nandokakimoto/9ceff49d4df07443407800aeb8315cd4 to your computer and use it in GitHub Desktop.
Simple Active Job example with shipping details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BillingService | |
def self.process(order, shipping_details) | |
Rails.logger.info "Processing order #{order.id} with details: #{shipping_details}..." | |
sleep(3) | |
Rails.logger.info "Order #{order.id} processed successfully." | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './app/services/billing_service' | |
class ProcessOrderJob < ApplicationJob | |
queue_as :default | |
def perform(order_id, shipping_details) | |
order = Order.find(order_id) | |
BillingService.process(order, shipping_details) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment