Class: Resque::MailQueue::EnqueueProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(klass, queue, options = {}) ⇒ EnqueueProxy

Returns a new instance of EnqueueProxy.


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

def initialize(klass, queue, options = {})
  @klass = klass
  @queue = queue
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/resque_mail_queue.rb', line 36

def method_missing(method, *args, &block)
  if @klass.respond_to? method
    @options.merge!({'klass' => @klass.to_s, 'method' => method, 'args' => args})

    if @queue
      Resque.enqueue_to(@queue, @klass, @options)
    else
      Resque.enqueue(@klass, @options)
    end
  else
    super
  end
end