Module: Delayed::MessageSending::ClassMethods

Defined in:
lib/delayed/message_sending.rb

Instance Method Summary collapse

Instance Method Details

#handle_asynchronously(method) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/delayed/message_sending.rb', line 12

def handle_asynchronously(method)
  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(without_method, *args)
  end
  alias_method_chain method, :send_later
end