module CruLib::Async
Public Instance Methods
async(method, *args)
click to toggle source
# File lib/cru_lib/async.rb, line 17 def async(method, *args) Sidekiq::Client.enqueue(self.class, id, method, *args) end
perform(id, method, *args)
click to toggle source
This will be called by a worker when a job needs to be processed
# File lib/cru_lib/async.rb, line 5 def perform(id, method, *args) if id begin self.class.find(id).send(method, *args) rescue ActiveRecord::RecordNotFound # If the record was deleted after the job was created, swallow it end else self.class.send(method, *args) end end