aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/CHANGELOG2
-rw-r--r--actionmailer/lib/action_mailer/base.rb24
2 files changed, 17 insertions, 9 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index 1d99448f62..d17955b7e9 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Move mailer initialization to a separate (overridable) method, so that subclasses may alter the various defaults #1727
+
* Look at content-location header (if available) to determine filename of attachments #1670
* ActionMailer::Base.deliver(email) had been accidentally removed, but was documented in the Rails book #1849
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index b76be81d5b..fe6a9a4ead 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -199,15 +199,7 @@ module ActionMailer #:nodoc:
# Initialize the mailer via the given +method_name+. The body will be
# rendered and a new TMail::Mail object created.
def create!(method_name, *parameters) #:nodoc:
- @bcc = @cc = @from = @recipients = @sent_on = @subject = nil
- @charset = @@default_charset.dup
- @content_type = @@default_content_type.dup
- @implicit_parts_order = @@default_implicit_parts_order.dup
- @template = method_name
- @parts = []
- @headers = {}
- @body = {}
-
+ initialize_defaults(method_name)
send(method_name, *parameters)
# If an explicit, textual body has not been set, we check assumptions.
@@ -268,6 +260,20 @@ module ActionMailer #:nodoc:
end
private
+ # Set up the default values for the various instance variables of this
+ # mailer. Subclasses may override this method to provide different
+ # defaults.
+ def initialize_defaults(method_name)
+ @bcc = @cc = @from = @recipients = @sent_on = @subject = nil
+ @charset = @@default_charset.dup
+ @content_type = @@default_content_type.dup
+ @implicit_parts_order = @@default_implicit_parts_order.dup
+ @template = method_name
+ @parts = []
+ @headers = {}
+ @body = {}
+ end
+
def render_message(method_name, body)
initialize_template_class(body).render_file(method_name)
end