aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-08-22 20:53:27 +0000
committerJamis Buck <jamis@37signals.com>2005-08-22 20:53:27 +0000
commitf474f337b16b3fb98d5fa39ed83056bc76c6f24a (patch)
tree350465fd34723b173e04c96e1d9f4deaf036d782 /actionmailer
parentb13efaf9855d5dc060972dae11ef97ab28c93e44 (diff)
downloadrails-f474f337b16b3fb98d5fa39ed83056bc76c6f24a.tar.gz
rails-f474f337b16b3fb98d5fa39ed83056bc76c6f24a.tar.bz2
rails-f474f337b16b3fb98d5fa39ed83056bc76c6f24a.zip
Move mailer initialization to a separate (overridable) method, so that subclasses may alter the various defaults #1727
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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