Class: ActionMailer::Base
- Inherits:
-
Object
- Object
- ActionMailer::Base
- Defined in:
- lib/theme_support/patches/actionmailer_ex.rb
Instance Attribute Summary collapse
-
#current_theme ⇒ Object
Returns the value of attribute current_theme.
Instance Method Summary collapse
- #__initialize ⇒ Object
-
#create!(method_name, *parameters) ⇒ Object
:nodoc:.
-
#initialize(method_name = nil, *parameters) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(method_name = nil, *parameters) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 |
# File 'lib/theme_support/patches/actionmailer_ex.rb', line 12 def initialize(method_name=nil, *parameters) if parameters[-1].is_a? Hash and (parameters[-1].include? :theme) @current_theme = parameters[-1][:theme] parameters[-1].delete :theme parameters[-1][:current_theme] = @current_theme end create!(method_name, *parameters) if method_name end |
Instance Attribute Details
#current_theme ⇒ Object
Returns the value of attribute current_theme.
10 11 12 |
# File 'lib/theme_support/patches/actionmailer_ex.rb', line 10 def current_theme @current_theme end |
Instance Method Details
#__initialize ⇒ Object
6 |
# File 'lib/theme_support/patches/actionmailer_ex.rb', line 6 alias_method :__initialize, :initialize |
#create!(method_name, *parameters) ⇒ Object
:nodoc:
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/theme_support/patches/actionmailer_ex.rb', line 21 def create!(method_name, *parameters) #:nodoc: initialize_defaults(method_name) __send__(method_name, *parameters) tpaths = [] tpaths << File.join(Rails.root, "themes", self.current_theme, "views", mailer_name) if self.current_theme tpaths << template_path # If an explicit, textual body has not been set, we check assumptions. unless String === @body # First, we look to see if there are any likely templates that match, # which include the content-type in their file name (i.e., # "the_template_file.text.html.erb", etc.). Only do this if parts # have not already been specified manually. if @parts.empty? tpaths.each do |tpath| Dir.glob("#{tpath}/#{@template}.*").each do |path| template = template_root["#{tpath}/#{File.basename(path)}"] # Skip unless template has a multipart format next unless template && template.multipart? @parts << Part.new( :content_type => template.content_type, :disposition => "inline", :charset => charset, :body => (template, @body) ) end break if @parts.any? end unless @parts.empty? @content_type = "multipart/alternative" @parts = sort_parts(@parts, @implicit_parts_order) end end # Then, if there were such templates, we check to see if we ought to # also render a "normal" template (without the content type). If a # normal template exists (or if there were no implicit parts) we render # it. template_exists = @parts.empty? tpaths.each do |tpath| template_exists ||= template_root["#{tpath}/#{@template}"] if template_exists @body = (@template, @body) break end end # Finally, if there are other message parts and a textual body exists, # we shift it onto the front of the parts and set the body to nil (so # that create_mail doesn't try to render it in addition to the parts). if !@parts.empty? && String === @body @parts.unshift Part.new(:charset => charset, :body => @body) @body = nil end end # If this is a multipart e-mail add the mime_version if it is not # already set. @mime_version ||= "1.0" if !@parts.empty? # build the mail object itself @mail = create_mail end |