Class: RunThisAsync::AsyncPlan

Inherits:
BasicObject
Defined in:
lib/run_this_async.rb

Instance Method Summary collapse

Constructor Details

#initialize(callee, expected_job_id) ⇒ AsyncPlan

Returns a new instance of AsyncPlan.



16
17
18
19
20
21
# File 'lib/run_this_async.rb', line 16

def initialize(callee, expected_job_id)
  @callee = ::RunThisAsync::Callee::Encoder.call(callee)
  @expected_job_id = expected_job_id
  @methods_to_call = []
  @with_args = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



29
30
31
32
33
34
# File 'lib/run_this_async.rb', line 29

def method_missing(name, *args)
  @methods_to_call << name
  @with_args << args

  self
end

Instance Method Details

#asyncObject



23
24
25
26
27
# File 'lib/run_this_async.rb', line 23

def async
  ::RunThisAsync::AsyncRunner.perform_async(
    @expected_job_id, @callee, @methods_to_call, @with_args
  )
end