From 7e0cf563639bc7508da381b1b8321c7a89be1aa8 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 28 Sep 2012 12:11:48 +0100 Subject: Support `Mailer.deliver_foo(*args)` as a synonym for `Mailer.foo(*args).deliver`. This makes it easy to write e.g. `Mailer.expects(:deliver_foo)` when testing code that calls the mailer. --- actionmailer/lib/action_mailer/base.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionmailer/lib') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index ff6911f44f..bd33f81f1e 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -142,6 +142,7 @@ module ActionMailer # for delivery later: # # Notifier.welcome(david).deliver # sends the email + # Notifier.deliver_welcome(david) # synonym for the former # mail = Notifier.welcome(david) # => a Mail::Message object # mail.deliver # sends the email # @@ -487,6 +488,8 @@ module ActionMailer def method_missing(method_name, *args) if action_methods.include?(method_name.to_s) QueuedMessage.new(queue, self, method_name, *args) + elsif method_name.to_s =~ /^deliver_(.+)$/ && action_methods.include?($1) + public_send($1, *args).deliver else super end -- cgit v1.2.3