split process from mailer instantiation

this allows us to construct mailer objects without possibly disastrous
side-effects.
This commit is contained in:
Aaron Patterson 2015-10-30 14:53:05 -07:00
parent d2315d0c3b
commit e76c38ef10
2 changed files with 6 additions and 5 deletions

@ -441,8 +441,6 @@ def _protected_ivars # :nodoc:
helper ActionMailer::MailHelper
private_class_method :new #:nodoc:
class_attribute :default_params
self.default_params = {
mime_version: "1.0",
@ -580,11 +578,10 @@ def method_missing(method_name, *args) # :nodoc:
# will be initialized according to the named method. If not, the mailer will
# remain uninitialized (useful when you only need to invoke the "receive"
# method, for instance).
def initialize(method_name=nil, *args)
def initialize
super()
@_mail_was_called = false
@_message = Mail.new
process(method_name, *args) if method_name
end
def process(method_name, *args) #:nodoc:

@ -21,7 +21,11 @@ def initialize(mailer, mail_method, *args) #:nodoc:
end
def __getobj__ #:nodoc:
@obj ||= @mailer.send(:new, @mail_method, *@args).message
@obj ||= begin
mailer = @mailer.new
mailer.process @mail_method, *@args
mailer.message
end
end
def __setobj__(obj) #:nodoc: