Class: SuckerPunch::Backgroundable::JobRunner
- Inherits:
-
Object
- Object
- SuckerPunch::Backgroundable::JobRunner
- Includes:
- CallMethod
- Defined in:
- lib/sucker_punch/backgroundable/job.rb
Instance Method Summary collapse
-
#initialize(receiver, method, args, options) ⇒ JobRunner
constructor
A new instance of JobRunner.
- #run(seconds = 0) ⇒ Object
Constructor Details
#initialize(receiver, method, args, options) ⇒ JobRunner
Returns a new instance of JobRunner.
45 46 47 |
# File 'lib/sucker_punch/backgroundable/job.rb', line 45 def initialize(receiver, method, args, ) @receiver, @method, @args, @options = receiver, method, args, end |
Instance Method Details
#run(seconds = 0) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sucker_punch/backgroundable/job.rb', line 49 def run(seconds = 0) if SuckerPunch::Backgroundable.configuration.enabled # run as SuckerPunch Job if seconds > 0 Job.perform_in(seconds, @receiver, @method, @args, @options) else Job.perform_async(@receiver, @method, @args, @options) end else # run without SuckerPunch or Celluloid @receiver = load(@receiver) if instantiate?(@options) call(@receiver, @method, *@args) end end |