Permalink
Browse files

Remove unused code paths and require mail only when it's needed.

  • Loading branch information...
1 parent c039bcd commit 616ebb8f6a5dc38a6fe0ee497f2059a9bd78a457 @josevalim josevalim committed Dec 28, 2009
View
3 actionmailer/lib/action_mailer.rb
@@ -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'
View
22 actionmailer/lib/action_mailer/base.rb
@@ -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 @@ def create_parts #: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 @@ def create_mail #: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 @@ def split_content_type(ct) #:nodoc:
end
def parse_content_type(defaults=nil) #:nodoc:
- if content_type.blank?
- if defaults
- [ defaults.content_type, { 'charset' => defaults.charset } ]
- else
- [ nil, {} ]
- end
+ if @content_type.blank?
+ [ nil, {} ]
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
View
1 actionmailer/lib/action_mailer/test_case.rb
@@ -1,4 +1,5 @@
require 'active_support/test_case'
+require 'mail'
module ActionMailer
class NonInferrableMailerError < ::StandardError

0 comments on commit 616ebb8

Please sign in to comment.