Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename 'defaults' class method to 'default' to reflect that it's a de…

…claration
  • Loading branch information...
commit 452bb1e48d7fa3dd4b2684d9d8ba3091200d59fe 1 parent 0797142
@jeremy jeremy authored
View
28 actionmailer/lib/action_mailer/base.rb
@@ -23,8 +23,8 @@ module ActionMailer #:nodoc:
# Examples:
#
# class Notifier < ActionMailer::Base
- # defaults :from => 'no-reply@example.com',
- # :return_path => 'system@example.com'
+ # default :from => 'no-reply@example.com',
+ # :return_path => 'system@example.com'
#
# def welcome(recipient)
# @account = recipient
@@ -191,7 +191,7 @@ module ActionMailer #:nodoc:
#
# These options are specified on the class level, like <tt>ActionMailer::Base.template_root = "/my/templates"</tt>
#
- # * <tt>defaults</tt> - This is a class wide hash of <tt>:key => value</tt> pairs containing
+ # * <tt>default</tt> - This is a class wide hash of <tt>:key => value</tt> pairs containing
# default values for the specified header fields of the <tt>Mail::Message</tt>. You can
# specify a default for any valid header for <tt>Mail::Message</tt> and it will be used if
# you do not override it. The defaults set by Action Mailer are:
@@ -232,16 +232,16 @@ module ActionMailer #:nodoc:
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with <tt>delivery_method :test</tt>. Most useful
# for unit and functional testing.
#
- # * <tt>default_charset</tt> - This is now deprecated, use the +defaults+ method above to
+ # * <tt>default_charset</tt> - This is now deprecated, use the +default+ method above to
# set the default +:charset+.
#
- # * <tt>default_content_type</tt> - This is now deprecated, use the +defaults+ method above
+ # * <tt>default_content_type</tt> - This is now deprecated, use the +default+ method above
# to set the default +:content_type+.
#
- # * <tt>default_mime_version</tt> - This is now deprecated, use the +defaults+ method above
+ # * <tt>default_mime_version</tt> - This is now deprecated, use the +default+ method above
# to set the default +:mime_version+.
#
- # * <tt>default_implicit_parts_order</tt> - This is now deprecated, use the +defaults+ method above
+ # * <tt>default_implicit_parts_order</tt> - This is now deprecated, use the +default+ method above
# to set the default +:parts_order+. Parts Order is used when a message is built implicitly
# (i.e. multiple parts are assembled from templates which specify the content type in their
# filenames) this variable controls how the parts are ordered.
@@ -280,7 +280,7 @@ def mailer_name
attr_writer :mailer_name
alias :controller_path :mailer_name
- def defaults(value=nil)
+ def default(value=nil)
self.default_params.merge!(value) if value
self.default_params
end
@@ -429,13 +429,13 @@ def attachments
# * <tt>:reply_to</tt> - Who to set the Reply-To header of the email to.
# * <tt>:date</tt> - The date to say the email was sent on.
#
- # You can set default values for any of the above headers (except :date) by using the <tt>defaults</tt>
+ # You can set default values for any of the above headers (except :date) by using the <tt>default</tt>
# class method:
#
# class Notifier < ActionMailer::Base
- # self.defaults :from => 'no-reply@test.lindsaar.net',
- # :bcc => 'email_logger@test.lindsaar.net',
- # :reply_to => 'bounces@test.lindsaar.net'
+ # self.default :from => 'no-reply@test.lindsaar.net',
+ # :bcc => 'email_logger@test.lindsaar.net',
+ # :reply_to => 'bounces@test.lindsaar.net'
# end
#
# If you need other headers not listed above, use the <tt>headers['name'] = value</tt> method.
@@ -487,7 +487,7 @@ def mail(headers={}, &block)
parts_order = headers[:parts_order]
# Merge defaults from class
- headers = headers.reverse_merge(self.class.defaults)
+ headers = headers.reverse_merge(self.class.default)
charset = headers[:charset]
# Quote fields
@@ -562,7 +562,7 @@ def collect_responses_and_parts_order(headers) #:nodoc:
elsif headers[:body]
responses << {
:body => headers[:body],
- :content_type => self.class.defaults[:content_type] || "text/plain"
+ :content_type => self.class.default[:content_type] || "text/plain"
}
else
each_template do |template|
View
4 actionmailer/lib/action_mailer/deprecated_api.rb
@@ -14,7 +14,7 @@ def self.default_#{method}
def self.default_#{method}=(value)
ActiveSupport::Deprecation.warn "ActionMailer::Base.default_#{method}=value is deprecated, " <<
- "use defaults :#{method} => value instead"
+ "use default :#{method} => value instead"
@@default_#{method} = value
end
@@ -136,4 +136,4 @@ def create_parts
end
end
-end
+end
View
10 actionmailer/lib/action_mailer/old_api.rb
@@ -187,10 +187,10 @@ def create_mail
# mailer. Subclasses may override this method to provide different
# defaults.
def initialize_defaults(method_name)
- @charset ||= self.class.defaults[:charset].try(:dup)
- @content_type ||= self.class.defaults[:content_type].try(:dup)
- @implicit_parts_order ||= self.class.defaults[:parts_order].try(:dup)
- @mime_version ||= self.class.defaults[:mime_version].try(:dup)
+ @charset ||= self.class.default[:charset].try(:dup)
+ @content_type ||= self.class.default[:content_type].try(:dup)
+ @implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
+ @mime_version ||= self.class.default[:mime_version].try(:dup)
@mailer_name ||= self.class.mailer_name.dup
@template ||= method_name
@@ -245,4 +245,4 @@ def parse_content_type(defaults=nil)
end
end
end
-end
+end
View
10 actionmailer/test/base_test.rb
@@ -5,9 +5,9 @@ class BaseTest < ActiveSupport::TestCase
class BaseMailer < ActionMailer::Base
self.mailer_name = "base_mailer"
- defaults :to => 'system@test.lindsaar.net',
- :from => 'jose@test.plataformatec.com',
- :reply_to => 'mikel@test.lindsaar.net'
+ default :to => 'system@test.lindsaar.net',
+ :from => 'jose@test.plataformatec.com',
+ :reply_to => 'mikel@test.lindsaar.net'
def welcome(hash = {})
headers['X-SPAM'] = "Not SPAM"
@@ -237,7 +237,7 @@ def custom_block(include_html=false)
end
test "subject gets default from I18n" do
- BaseMailer.defaults[:subject] = nil
+ BaseMailer.default[:subject] = nil
email = BaseMailer.welcome(:subject => nil)
assert_equal "Welcome", email.subject
@@ -473,7 +473,7 @@ def swap(klass, new_values)
end
def with_default(klass, new_values)
- hash = klass.defaults
+ hash = klass.default
old_values = {}
new_values.each do |key, value|
old_values[key] = hash[key]
View
2  railties/test/generators/mailer_generator_test.rb
@@ -9,7 +9,7 @@ def test_mailer_skeleton_is_created
run_generator
assert_file "app/mailers/notifier.rb" do |mailer|
assert_match /class Notifier < ActionMailer::Base/, mailer
- assert_match /defaults :from => "from@example.com"/, mailer
+ assert_match /default :from => "from@example.com"/, mailer
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.