Class: TResque::Delay::InvocationProxy
- Inherits:
-
Object
- Object
- TResque::Delay::InvocationProxy
- Defined in:
- lib/tresque/delay.rb
Instance Method Summary collapse
-
#initialize(object, options = {}) ⇒ InvocationProxy
constructor
A new instance of InvocationProxy.
- #method_missing(method_name, *args) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
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, = {}) @object = object @run_at = [:run_at] @run_at ||= (!![:force] ? true : nil) @synchronous = !![:synchronous] @queue_namespace = [:queue_namespace] || Util.calculate_namespace_from_class(object) @queue_name = [:queue] || 'default' @lock_namespace = [:lock_namespace] @queue_lock_key = [:queue_lock_key] @worker_lock_key = [: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
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 |