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 @options = {:queue => "default"}.update() 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 = @options[:queue] || @payload_class.queue performable = @payload_class.new(@target, method.to_sym, @options, args) if @options[:unique] if @options[:run_at] or @options[:in] ::Resque.remove_delayed(@payload_class, performable.store) else ::Resque.dequeue(@payload_class, performable.store) end end if @options[:run_at] ::Resque.enqueue_at(@options[:run_at], @payload_class, performable.store) elsif @options[:in] ::Resque.enqueue_in(@options[:in], @payload_class, performable.store) else ::Resque.enqueue_to(queue, @payload_class, performable.store) end end |