mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove unused code paths and require mail only when it's needed.
This commit is contained in:
parent
c039bcdb1c
commit
616ebb8f6a
3 changed files with 9 additions and 17 deletions
|
@ -24,7 +24,6 @@
|
|||
actionpack_path = File.expand_path('../../../actionpack/lib', __FILE__)
|
||||
$:.unshift(actionpack_path) if File.directory?(actionpack_path) && !$:.include?(actionpack_path)
|
||||
|
||||
|
||||
require 'action_controller'
|
||||
require 'action_view'
|
||||
|
||||
|
@ -46,5 +45,3 @@ module Text
|
|||
|
||||
autoload :Format, 'action_mailer/vendor/text_format'
|
||||
end
|
||||
|
||||
require 'mail'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'active_support/core_ext/class'
|
||||
require 'mail'
|
||||
|
||||
module ActionMailer #:nodoc:
|
||||
# Action Mailer allows you to send email from your application using a mailer model and views.
|
||||
|
@ -534,7 +535,7 @@ module ActionMailer #:nodoc:
|
|||
if String === response_body
|
||||
@parts.unshift create_inline_part(response_body)
|
||||
else
|
||||
self.class.template_root.find_all(@template, {}, mailer_name).each do |template|
|
||||
self.class.template_root.find_all(@template, {}, @mailer_name).each do |template|
|
||||
@parts << create_inline_part(render_to_body(:_template => template), template.mime_type)
|
||||
end
|
||||
|
||||
|
@ -575,17 +576,14 @@ module ActionMailer #:nodoc:
|
|||
real_content_type, ctype_attrs = parse_content_type
|
||||
main_type, sub_type = split_content_type(real_content_type)
|
||||
|
||||
if @parts.empty?
|
||||
m.content_type([main_type, sub_type, ctype_attrs])
|
||||
m.body = body
|
||||
elsif @parts.size == 1 && @parts.first.parts.empty?
|
||||
if @parts.size == 1 && @parts.first.parts.empty?
|
||||
m.content_type([main_type, sub_type, ctype_attrs])
|
||||
m.body = @parts.first.body.encoded
|
||||
else
|
||||
|
||||
@parts.each do |p|
|
||||
m.add_part(p)
|
||||
end
|
||||
|
||||
m.body.set_sort_order(@implicit_parts_order)
|
||||
m.body.sort_parts!
|
||||
|
||||
|
@ -603,16 +601,12 @@ module ActionMailer #:nodoc:
|
|||
end
|
||||
|
||||
def parse_content_type(defaults=nil) #:nodoc:
|
||||
if content_type.blank?
|
||||
if defaults
|
||||
[ defaults.content_type, { 'charset' => defaults.charset } ]
|
||||
else
|
||||
if @content_type.blank?
|
||||
[ nil, {} ]
|
||||
end
|
||||
else
|
||||
ctype, *attrs = content_type.split(/;\s*/)
|
||||
ctype, *attrs = @content_type.split(/;\s*/)
|
||||
attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
|
||||
[ctype, {"charset" => charset || defaults && defaults.charset}.merge(attrs)]
|
||||
[ctype, {"charset" => @charset}.merge(attrs)]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'active_support/test_case'
|
||||
require 'mail'
|
||||
|
||||
module ActionMailer
|
||||
class NonInferrableMailerError < ::StandardError
|
||||
|
|
Loading…
Reference in a new issue