Class: ActiveWorker::JobQueue::RunRemotely::RemoteRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/active_worker/job_queue/run_remotely.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ RemoteRunner

Returns a new instance of RemoteRunner.



20
21
22
# File 'lib/active_worker/job_queue/run_remotely.rb', line 20

def initialize(klass)
  @klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *params) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_worker/job_queue/run_remotely.rb', line 24

def method_missing(method,*params)
  args = construct_args(method,params)
  thread = nil
  case RunRemotely.worker_mode
    when THREADED
      thread = Thread.new do
        ActiveWorker::JobQueue::JobExecuter.execute_task_from_args(args)
      end
    when RESQUE
      Resque.enqueue(JobExecuter,args)
  end
  thread
end

Instance Method Details

#construct_args(method, params) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/active_worker/job_queue/run_remotely.rb', line 38

def construct_args(method, params)
  {
      "class_name" => @klass.to_s,
      "method"     => method.to_s,
      "params"     => params
  }
end