Module: Delayed::MessageSending::ClassMethods

Defined in:
lib/delayed/message_sending.rb

Instance Method Summary collapse

Instance Method Details

#handle_asynchronously(method, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/delayed/message_sending.rb', line 35

def handle_asynchronously(method, options = {})
  aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
  with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"
  define_method(with_method) do |*args|
    delay(options).__send__(without_method, *args)
  end
  alias_method_chain method, :delay
end