Class: ResqueDelayWithMongoid::DelayProxy

Inherits:
ActiveSupport::BasicObject
Defined in:
lib/resque_delay_with_mongoid/message_sending.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, options) ⇒ DelayProxy

Returns a new instance of DelayProxy.



5
6
7
8
# File 'lib/resque_delay_with_mongoid/message_sending.rb', line 5

def initialize(target, options)
  @target = target
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



10
11
12
13
14
# File 'lib/resque_delay_with_mongoid/message_sending.rb', line 10

def method_missing(method, *args)
  queue = @options[:to] || :default
  performable_method = PerformableMethod.create(@target, method, args)
  ::Resque::Job.create(queue, DelayProxy, performable_method.resque_args)
end

Class Method Details

.perform(args) ⇒ Object

Called asynchrously by Resque



17
18
19
# File 'lib/resque_delay_with_mongoid/message_sending.rb', line 17

def self.perform(args)
  PerformableMethod.new(*args).perform
end