Module: TResque::Delay::ClassMethods

Defined in:
lib/tresque/delay.rb

Instance Method Summary collapse

Instance Method Details

#async(method_name, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/tresque/delay.rb', line 12

def async(method_name, options = {})
  raise "Attempted to handle #{self.name}##{method_name} asyncronously but #{method_name} was not yet defined" unless (self.instance_methods + self.private_instance_methods).include?(method_name)

  class_eval <<-EV, __FILE__, __LINE__ + 1
    def #{method_name}_with_delay(*args)
      self.delay(#{options.inspect}).#{method_name}_without_delay(*args)
    end
    alias_method_chain :#{method_name}, :delay
  EV
end

#delay(options = {}) ⇒ Object



7
8
9
# File 'lib/tresque/delay.rb', line 7

def delay(options = {})
  InvocationProxy.new(self, options)
end