Skip to content

Instantly share code, notes, and snippets.

@nandokakimoto
Created March 27, 2017 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nandokakimoto/e55d28ce097672f5a50ed717aedebdf7 to your computer and use it in GitHub Desktop.
Save nandokakimoto/e55d28ce097672f5a50ed717aedebdf7 to your computer and use it in GitHub Desktop.
Simple Active Job example with shipping details (backward compatible)
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
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