class RunThisAsync::AsyncRunner

Public Instance Methods

perform(expected_job_id, callee, method, args = nil) click to toggle source
# File lib/run_this_async/async_runner.rb, line 7
def perform(expected_job_id, callee, method, args = nil)
  return if unexpected_job_id?(expected_job_id)

  callee = RunThisAsync::Callee::Decoder.call(callee)

  if method.is_a?(Array)
    send_chain_of_methods(callee, method, args)
  else
    send_method_to_callee(callee, method, args)
  end
end

Private Instance Methods

send_chain_of_methods(callee, methods, arrays_of_args) click to toggle source
# File lib/run_this_async/async_runner.rb, line 24
def send_chain_of_methods(callee, methods, arrays_of_args)
  return callee if methods.empty?

  send_chain_of_methods(
    callee.send(methods.shift, *arrays_of_args.shift),
    methods,
    arrays_of_args
  )
end
send_method_to_callee(callee, method, args) click to toggle source
# File lib/run_this_async/async_runner.rb, line 20
def send_method_to_callee(callee, method, args)
  callee.send(method, *args)
end
unexpected_job_id?(expected_job_id) click to toggle source
# File lib/run_this_async/async_runner.rb, line 34
def unexpected_job_id?(expected_job_id)
  expected_job_id && expected_job_id != jid
end