From f474f337b16b3fb98d5fa39ed83056bc76c6f24a Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 22 Aug 2005 20:53:27 +0000 Subject: 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 --- actionmailer/lib/action_mailer/base.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'actionmailer/lib') 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 -- cgit v1.2.3