Commit
Mailer.deliver_foo(*args)
as a synonym for `Mailer.foo(*arg…
…s).deliver`. This makes it easy to write e.g. `Mailer.expects(:deliver_foo)` when testing code that calls the mailer.
- Loading branch information
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -142,6 +142,7 @@ module ActionMailer | ||
# for delivery later: | # for delivery later: | ||
# | # | ||
# Notifier.welcome(david).deliver # sends the email | # Notifier.welcome(david).deliver # sends the email | ||
# Notifier.deliver_welcome(david) # synonym for the former | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jonleighton
Author
Member
|
|||
# mail = Notifier.welcome(david) # => a Mail::Message object | # mail = Notifier.welcome(david) # => a Mail::Message object | ||
# mail.deliver # sends the email | # mail.deliver # sends the email | ||
# | # | ||
|
@@ -487,6 +488,8 @@ def set_payload_for_mail(payload, mail) #:nodoc: | ||
def method_missing(method_name, *args) | def method_missing(method_name, *args) | ||
if action_methods.include?(method_name.to_s) | if action_methods.include?(method_name.to_s) | ||
QueuedMessage.new(queue, self, method_name, *args) | QueuedMessage.new(queue, self, method_name, *args) | ||
elsif method_name.to_s =~ /^deliver_(.+)$/ && action_methods.include?($1) | |||
public_send($1, *args).deliver | |||
else | else | ||
super | super | ||
end | end | ||
|
This is an interesting addition, considering it was deprecated in ActionMailer 3.0 - see line 108 and this post among other resources.
I don't personally care for this addition and I'm interested to hear what other opinions are on this.