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.



11
12
13
14
# File 'lib/message/worker.rb', line 11

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



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

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
  Message.worker(@job) << [@obj, m, args]
end