Class: TResque::Delay::InvocationProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(object, options = {}) ⇒ InvocationProxy

Returns a new instance of InvocationProxy.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/tresque/delay.rb', line 45

def initialize(object, options = {})

  @object = object
  @run_at = options[:run_at]
  @run_at ||= (!!options[:force] ? true : nil)
  @synchronous = !!options[:synchronous]

  @queue_namespace  = options[:queue_namespace] || Util.calculate_namespace_from_class(object)
  @queue_name       = options[:queue] || 'default'

  @lock_namespace   = options[:lock_namespace]
  @queue_lock_key   = options[:queue_lock_key]
  @worker_lock_key  = options[:worker_lock_key]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/tresque/delay.rb', line 60

def method_missing(method_name, *args)
  if !@synchronous && (!in_resque? || @run_at == true || @run_at.to_i > Time.now.to_i)
    @method_name = method_name.to_s
    @args = args
    queue_delayed_invocation!
  else
    @object.send(method_name, *args)
  end
end

Instance Method Details

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
# File 'lib/tresque/delay.rb', line 70

def respond_to?(*args)
  return true unless in_resque?
  @object.respond_to?(*args)
end