diff options
Diffstat (limited to 'actionmailer/lib')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 5 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/collector.rb | 11 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/old_api.rb | 4 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 4 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railties/log_subscriber.rb | 6 |
5 files changed, 14 insertions, 16 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f94e23fe05..1dc2d92c43 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -1,6 +1,7 @@ require 'mail' require 'action_mailer/tmail_compat' require 'action_mailer/collector' +require 'active_support/core_ext/array/wrap' module ActionMailer #:nodoc: # Action Mailer allows you to send email from your application using a mailer model and views. @@ -604,6 +605,8 @@ module ActionMailer #:nodoc: templates_name = headers.delete(:template_name) || action_name each_template(templates_path, templates_name) do |template| + self.formats = template.formats + responses << { :body => render(:template => template), :content_type => template.mime_type.to_s @@ -615,7 +618,7 @@ module ActionMailer #:nodoc: end def each_template(paths, name, &block) #:nodoc: - Array(paths).each do |path| + Array.wrap(paths).each do |path| templates = lookup_context.find_all(name, path) templates = templates.uniq_by { |t| t.formats } diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb index 5431efccfe..bd4f76bbb6 100644 --- a/actionmailer/lib/action_mailer/collector.rb +++ b/actionmailer/lib/action_mailer/collector.rb @@ -11,7 +11,6 @@ module ActionMailer #:nodoc: @context = context @responses = [] @default_render = block - @default_formats = context.formats end def any(*args, &block) @@ -21,16 +20,12 @@ module ActionMailer #:nodoc: end alias :all :any - def custom(mime, options={}, &block) + def custom(mime, options={}) options.reverse_merge!(:content_type => mime.to_s) @context.formats = [mime.to_sym] - options[:body] = if block - block.call - else - @default_render.call - end + @context.formats.freeze + options[:body] = block_given? ? yield : @default_render.call @responses << options - @context.formats = @default_formats end end end
\ No newline at end of file diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index fb4b6701dd..c7f341d46c 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -31,9 +31,6 @@ module ActionMailer # replies to this message. adv_attr_accessor :reply_to - # Specify additional headers to be added to the message. - adv_attr_accessor :headers - # Specify the order in which parts should be sorted, based on content-type. # This defaults to the value for the +default_implicit_parts_order+. adv_attr_accessor :implicit_parts_order @@ -207,6 +204,7 @@ module ActionMailer @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } lookup_context.find_all(@template, @mailer_name).each do |template| + self.formats = template.formats @parts << create_inline_part(render(:template => template), template.mime_type) end diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 0182e48425..2703367fdb 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -3,14 +3,14 @@ require "rails" module ActionMailer class Railtie < Rails::Railtie - railtie_name :action_mailer + config.action_mailer = ActiveSupport::OrderedOptions.new initializer "action_mailer.url_for", :before => :load_environment_config do |app| ActionMailer.base_hook { include app.routes.url_helpers } end require "action_mailer/railties/log_subscriber" - log_subscriber ActionMailer::Railties::LogSubscriber.new + log_subscriber :action_mailer, ActionMailer::Railties::LogSubscriber.new initializer "action_mailer.logger" do ActionMailer.base_hook { self.logger ||= Rails.logger } diff --git a/actionmailer/lib/action_mailer/railties/log_subscriber.rb b/actionmailer/lib/action_mailer/railties/log_subscriber.rb index d1b3dd33af..af76d807d0 100644 --- a/actionmailer/lib/action_mailer/railties/log_subscriber.rb +++ b/actionmailer/lib/action_mailer/railties/log_subscriber.rb @@ -1,8 +1,10 @@ +require 'active_support/core_ext/array/wrap' + module ActionMailer module Railties class LogSubscriber < Rails::LogSubscriber def deliver(event) - recipients = Array(event.payload[:to]).join(', ') + recipients = Array.wrap(event.payload[:to]).join(', ') info("\nSent mail to #{recipients} (%1.fms)" % event.duration) debug(event.payload[:mail]) end @@ -17,4 +19,4 @@ module ActionMailer end end end -end
\ No newline at end of file +end |