diff options
author | hnatt <hnatt88@gmail.com> | 2015-10-29 21:27:21 +0200 |
---|---|---|
committer | hnatt <hnatt88@gmail.com> | 2015-10-29 21:28:22 +0200 |
commit | 8c566b9a94c99ef218a0778310ab8ffc306aff1d (patch) | |
tree | 572e1908868044c67f7177939c9ab4f0f04f0c2e /actionmailer | |
parent | e71cfc109dd2204efe35f1ffa927bdc08bd9999b (diff) | |
download | rails-8c566b9a94c99ef218a0778310ab8ffc306aff1d.tar.gz rails-8c566b9a94c99ef218a0778310ab8ffc306aff1d.tar.bz2 rails-8c566b9a94c99ef218a0778310ab8ffc306aff1d.zip |
Refactor ActionMailer::Base#collect_responses
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 00fa67e460..9f26a3874c 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -879,33 +879,33 @@ module ActionMailer end def collect_responses(headers) #:nodoc: - responses = [] - if block_given? collector = ActionMailer::Collector.new(lookup_context) { render(action_name) } yield(collector) - responses = collector.responses + collector.responses elsif headers[:body] - responses << { + [{ body: headers.delete(:body), content_type: self.class.default[:content_type] || "text/plain" - } + }] else - templates_path = headers.delete(:template_path) || self.class.mailer_name - templates_name = headers.delete(:template_name) || action_name + collect_responses_from_templates(headers) + end + end - each_template(Array(templates_path), templates_name) do |template| - self.formats = template.formats + def collect_responses_from_templates(headers) + templates_path = headers.delete(:template_path) || self.class.mailer_name + templates_name = headers.delete(:template_name) || action_name - responses << { - body: render(template: template), - content_type: template.type.to_s - } - end + each_template(Array(templates_path), templates_name).map do |template| + self.formats = template.formats + { + body: render(template: template), + content_type: template.type.to_s + } end - - responses end + private :collect_responses_from_templates def each_template(paths, name, &block) #:nodoc: templates = lookup_context.find_all(name, paths) |