Class: Message::Worker::Enqueue::Enq

Inherits:
Object
  • Object
show all
Defined in:
lib/message/worker.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj, job) ⇒ Enq

Returns a new instance of Enq.



9
10
11
12
# File 'lib/message/worker.rb', line 9

def initialize(obj, job)
  @obj = obj
  @job = job
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/message/worker.rb', line 14

def method_missing(m, *args, &block)
  if block_given?
    raise ArgumentError, "Can't enqueue with block call."
  end
  unless @obj.respond_to?(m)
    raise NoMethodError, "undefined method `#{m}' for #{@obj.inspect}"
  end
  Worker.enq(@job, [@obj, m, args])
end