aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-24 17:31:18 +0100
committerJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-24 17:31:18 +0100
commitf30d73bab4c676b187276797ac2a6dc89132c43f (patch)
tree36cb0f1f3aaa3edf5b7daee48df69d22ae21ba34 /actionmailer/lib
parent7409b734841c8bd691006634dd072212aa905cf4 (diff)
downloadrails-f30d73bab4c676b187276797ac2a6dc89132c43f.tar.gz
rails-f30d73bab4c676b187276797ac2a6dc89132c43f.tar.bz2
rails-f30d73bab4c676b187276797ac2a6dc89132c43f.zip
Add new class delivery method API.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/base.rb18
-rw-r--r--actionmailer/lib/action_mailer/deprecated_api.rb25
2 files changed, 32 insertions, 11 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index b881611cfb..8e30c54c49 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -253,6 +253,8 @@ module ActionMailer #:nodoc:
# and appear last in the mime encoded message. You can also pick a different order from inside a method with
# +implicit_parts_order+.
class Base < AbstractController::Base
+ abstract!
+
include Quoting
include AbstractController::Logger
@@ -264,8 +266,8 @@ module ActionMailer #:nodoc:
helper ActionMailer::MailHelper
- include ActionMailer::DeprecatedApi
extend ActionMailer::DeliveryMethods
+ include ActionMailer::DeprecatedApi
add_delivery_method :smtp, Mail::SMTP,
:address => "localhost",
@@ -370,6 +372,20 @@ module ActionMailer #:nodoc:
payload[:date] = mail.date
payload[:mail] = mail.encoded
end
+
+ def respond_to?(method, *args)
+ super || action_methods.include?(method.to_s)
+ end
+
+ protected
+
+ def method_missing(method, *args)
+ if action_methods.include?(method.to_s)
+ new(method, *args).message
+ else
+ super
+ end
+ end
end
attr_internal :message
diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb
index f969584a17..f36b1befd6 100644
--- a/actionmailer/lib/action_mailer/deprecated_api.rb
+++ b/actionmailer/lib/action_mailer/deprecated_api.rb
@@ -1,8 +1,8 @@
module ActionMailer
- # TODO Remove this module all together in Rails 3.1. Ensure that super
- # hooks in ActionMailer::Base are removed as well.
- #
- # Moved here to allow us to add the new Mail API
+ # Part of this API is deprecated and is going to be removed in Rails 3.1 (just check
+ # the methods which give you a warning).
+ # All the rest will be deprecated after 3.1 release instead, this allows a smoother
+ # migration path.
module DeprecatedApi #:nodoc:
extend ActiveSupport::Concern
@@ -83,8 +83,8 @@ module ActionMailer
# MyMailer.deliver(email)
def deliver(mail, show_warning=true)
if show_warning
- ActiveSupport::Deprecation.warn "ActionMailer::Base.deliver is deprecated, just call " <<
- "deliver in the instance instead", caller
+ ActiveSupport::Deprecation.warn "#{self}.deliver is deprecated, call " <<
+ "deliver in the mailer instance instead", caller[0,2]
end
raise "no mail object available for delivery!" unless mail
@@ -100,9 +100,14 @@ module ActionMailer
def method_missing(method_symbol, *parameters) #:nodoc:
if match = matches_dynamic_method?(method_symbol)
case match[1]
- when 'create' then new(match[2], *parameters).message
- when 'deliver' then new(match[2], *parameters).deliver!
- when 'new' then nil
+ when 'create'
+ ActiveSupport::Deprecation.warn "#{self}.create_#{match[2]} is deprecated, " <<
+ "use #{self}.#{match[2]} instead", caller[0,2]
+ new(match[2], *parameters).message
+ when 'deliver'
+ ActiveSupport::Deprecation.warn "#{self}.deliver_#{match[2]} is deprecated, " <<
+ "use #{self}.#{match[2]}.deliver instead", caller[0,2]
+ new(match[2], *parameters).deliver
else super
end
else
@@ -167,7 +172,6 @@ module ActionMailer
# Add an attachment to a multipart message. This is simply a part with the
# content-disposition set to "attachment".
def attachment(params, &block)
- ActiveSupport::Deprecation.warn "attachment is deprecated, please use the attachments API instead", caller[0,2]
params = { :content_type => params } if String === params
params[:content] ||= params.delete(:data) || params.delete(:body)
@@ -259,6 +263,7 @@ module ActionMailer
end
end
+ wrap_delivery_behavior!
m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
@_message