Class: DelayedResque::DelayProxy
- Inherits:
-
Object
- Object
- DelayedResque::DelayProxy
- Defined in:
- lib/delayed_resque/message_sending.rb
Instance Method Summary collapse
-
#initialize(payload_class, target, options) ⇒ DelayProxy
constructor
A new instance of DelayProxy.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(payload_class, target, options) ⇒ DelayProxy
Returns a new instance of DelayProxy.
4 5 6 7 8 |
# File 'lib/delayed_resque/message_sending.rb', line 4 def initialize(payload_class, target, ) @payload_class = payload_class @target = target = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/delayed_resque/message_sending.rb', line 10 def method_missing(method, *args) queue = [:queue] || @payload_class.queue performable = @payload_class.new(@target, method.to_sym, , args) if [:unique] if [:run_at] or [:in] ::Resque.remove_delayed(@payload_class, performable.store) else ::Resque.dequeue(@payload_class, performable.store) end end if [:run_at] ::Resque.enqueue_at([:run_at], @payload_class, performable.store) elsif [:in] ::Resque.enqueue_in([:in], @payload_class, performable.store) else ::Resque.enqueue_to(queue, @payload_class, performable.store) end end |