module SuckerPunch::Job
Include this module in your job class to create asynchronous jobs:
class LogJob
include SuckerPunch::Job workers 4 def perform(*args) # log the things end
end
To trigger asynchronous job:
LogJob.perform_async(1, 2, 3) LogJob.perform_in(60, 1, 2, 3) # `perform` will be executed 60 sec. later
Note that perform_async is a class method, perform is an instance method.
Public Class Methods
clear_all()
click to toggle source
# File lib/sucker_punch/testing.rb, line 27 def self.clear_all end
included(base)
click to toggle source
# File lib/sucker_punch/job.rb, line 21 def self.included(base) base.extend(ClassMethods) base.class_attribute :num_workers base.class_attribute :num_jobs_max base.num_workers = 2 base.num_jobs_max = nil end
jobs()
click to toggle source
# File lib/sucker_punch/testing.rb, line 23 def self.jobs SuckerPunch::Queue.find_or_create(self.to_s) end
Public Instance Methods
async()
click to toggle source
# File lib/sucker_punch/async_syntax.rb, line 3 def async AsyncProxy.new(self) end
logger()
click to toggle source
# File lib/sucker_punch/job.rb, line 30 def logger SuckerPunch.logger end