Module: Delayed::MessageSending::ClassMethods
- Defined in:
- lib/delayed/message_sending.rb
Instance Method Summary collapse
- #add_send_later_methods(method, enqueue_args = {}, default_async = false) ⇒ Object
- #handle_asynchronously(method, enqueue_args = {}) ⇒ Object
- #handle_asynchronously_if_production(method, enqueue_args = {}) ⇒ Object
- #handle_asynchronously_with_queue(method, queue) ⇒ Object
Instance Method Details
#add_send_later_methods(method, enqueue_args = {}, default_async = false) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/delayed/message_sending.rb', line 98 def add_send_later_methods(method, enqueue_args={}, default_async=false) aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 with_method, without_method = "#{aliased_method}_with_send_later#{punctuation}", "#{aliased_method}_without_send_later#{punctuation}" define_method(with_method) do |*args| send_later_enqueue_args(without_method, enqueue_args, *args) end alias_method without_method, method if default_async alias_method method, with_method case when public_method_defined?(without_method) public method when protected_method_defined?(without_method) protected method when private_method_defined?(without_method) private method end end end |
#handle_asynchronously(method, enqueue_args = {}) ⇒ Object
121 122 123 |
# File 'lib/delayed/message_sending.rb', line 121 def handle_asynchronously(method, enqueue_args={}) add_send_later_methods(method, enqueue_args, true) end |
#handle_asynchronously_if_production(method, enqueue_args = {}) ⇒ Object
129 130 131 |
# File 'lib/delayed/message_sending.rb', line 129 def handle_asynchronously_if_production(method, enqueue_args={}) add_send_later_methods(method, enqueue_args, Rails.env.production?) end |
#handle_asynchronously_with_queue(method, queue) ⇒ Object
125 126 127 |
# File 'lib/delayed/message_sending.rb', line 125 def handle_asynchronously_with_queue(method, queue) add_send_later_methods(method, {:queue => queue}, true) end |