<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,4 @@
-require &quot;active_support/core_ext/class&quot;
-# Use the old layouts until actionmailer gets refactored
-require &quot;action_controller/legacy/layout&quot;
+require 'active_support/core_ext/class'
 
 module ActionMailer #:nodoc:
   # Action Mailer allows you to send email from your application using a mailer model and views.
@@ -254,11 +252,12 @@ module ActionMailer #:nodoc:
   #   +implicit_parts_order+.
   class Base
     include AdvAttrAccessor, PartContainer, Quoting, Utils
-    extend AbstractController::RenderingController
+
+    include AbstractController::RenderingController
+    include AbstractController::Layouts
 
     if Object.const_defined?(:ActionController)
       include ActionController::UrlWriter
-      include ActionController::Layout
     end
 
     private_class_method :new #:nodoc:
@@ -569,8 +568,7 @@ module ActionMailer #:nodoc:
         end
         
         @template = initialize_template_class(body)
-        layout = _pick_layout(layout, true) unless 
-          ActionController::Base.exempt_from_layout.include?(template.handler)
+        layout = _layout_for_option(:default, :formats =&gt; formats)
         @template._render_template(template, layout, {})
       ensure
         @current_template_content_type = nil
@@ -583,25 +581,23 @@ module ActionMailer #:nodoc:
       end
 
       def render(opts)
+        file = opts[:file]
         opts[:locals] ||= {}
-        layout, file = opts.delete(:layout), opts[:file]
-        
-        begin
-          @template = initialize_template_class(opts.delete(:body))
-          
-          if file
-            prefix = mailer_name unless file =~ /\//
-            template = view_paths.find(file, {:formats =&gt; formats}, prefix)
-          end
 
-          layout = _pick_layout(layout, 
-            !template || ActionController::Base.exempt_from_layout.include?(template.handler))
+        @template = initialize_template_class(opts.delete(:body))
 
-          if template
-            @template._render_template(template, layout, opts)
-          elsif inline = opts[:inline]
-            @template._render_inline(inline, layout, opts)
-          end
+        if file
+          prefix = mailer_name unless file =~ /\//
+          template = view_paths.find(file, {:formats =&gt; formats}, prefix)
+        end
+
+        layout = opts.key?(:layout) ? opts.delete(:layout) : :default
+        layout = _layout_for_option(layout, :formats =&gt; formats)
+
+        if template
+          @template._render_template(template, layout, opts)
+        elsif inline = opts[:inline]
+          @template._render_inline(inline, layout, opts)
         end
       end
 </diff>
      <filename>actionmailer/lib/action_mailer/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,10 +2,10 @@ require &quot;active_support/core_ext/class&quot;
 module ActionMailer
   module DeliveryMethod
 
-    autoload :File, 'action_mailer/delivery_method/file'
+    autoload :File,     'action_mailer/delivery_method/file'
     autoload :Sendmail, 'action_mailer/delivery_method/sendmail'
-    autoload :Smtp, 'action_mailer/delivery_method/smtp'
-    autoload :Test, 'action_mailer/delivery_method/test'
+    autoload :Smtp,     'action_mailer/delivery_method/smtp'
+    autoload :Test,     'action_mailer/delivery_method/test'
 
     # Creates a new DeliveryMethod object according to the given options.
     #
@@ -27,18 +27,17 @@ module ActionMailer
     def self.lookup_method(delivery_method)
       case delivery_method
       when Symbol
-        method_name = delivery_method.to_s.camelize
+        method_name  = delivery_method.to_s.camelize
         method_class = ActionMailer::DeliveryMethod.const_get(method_name)
-        method_class.new()
-      when nil
+        method_class.new
+      when nil # default
         Smtp.new
       else
         delivery_method
       end
     end
 
-    # An abstract delivery method class. There are multiple delivery method
-    # classes, documented under
+    # An abstract delivery method class. There are multiple delivery method classes.
     # See the classes under the ActionMailer::DeliveryMethod, e.g.
     # ActionMailer::DeliveryMethod::Smtp.
     # Smtp is the default delivery method for production
@@ -47,8 +46,8 @@ module ActionMailer
     # each delivery method exposes just one method
     #
     #   delivery_method = ActionMailer::DeliveryMethod::Smtp.new
-    #
     #   delivery_method.perform_delivery(mail) # send the mail via smtp
+    #
     class Method
       superclass_delegating_accessor :settings
       self.settings = {}</diff>
      <filename>actionmailer/lib/action_mailer/delivery_method.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,10 @@
 require 'tmpdir'
+
 module ActionMailer
   module DeliveryMethod
 
     # A delivery method implementation which writes all mails to a file.
     class File &lt; Method
-
       self.settings = {
         :location       =&gt; defined?(Rails) ? &quot;#{Rails.root}/tmp/mails&quot; : &quot;#{Dir.tmpdir}/mails&quot;
       }</diff>
      <filename>actionmailer/lib/action_mailer/delivery_method/file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ module ActionMailer
 
     # A delivery method implementation which sends via sendmail.
     class Sendmail &lt; Method
-
       self.settings = {
         :location       =&gt; '/usr/sbin/sendmail',
         :arguments      =&gt; '-i -t'
@@ -18,5 +17,6 @@ module ActionMailer
         end
       end
     end
+
   end
 end</diff>
      <filename>actionmailer/lib/action_mailer/delivery_method/sendmail.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
 module ActionMailer
   module DeliveryMethod
-    
     # A delivery method implementation which sends via smtp.
     class Smtp &lt; Method
 
@@ -27,5 +26,6 @@ module ActionMailer
         end
       end
     end
+
   end
 end</diff>
      <filename>actionmailer/lib/action_mailer/delivery_method/smtp.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,10 @@ module ActionMailer
 
     # A delivery method implementation designed for testing, which just appends each record to the :deliveries array
     class Test &lt; Method
-
       def perform_delivery(mail)
         ActionMailer::Base.deliveries &lt;&lt; mail
       end
     end
+
   end
 end</diff>
      <filename>actionmailer/lib/action_mailer/delivery_method/test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -171,6 +171,26 @@ module AbstractController
       name &amp;&amp; _find_layout(name, details)
     end
 
+    # Determine the layout for a given name and details, taking into account
+    # the name type.
+    #
+    # ==== Parameters
+    # name&lt;String|TrueClass|FalseClass|Symbol&gt;:: The name of the template
+    # details&lt;Hash{Symbol =&gt; Object}&gt;:: A list of details to restrict
+    #   the lookup to. By default, layout lookup is limited to the
+    #   formats specified for the current request.
+    def _layout_for_option(name, details)
+      case name
+      when String     then _layout_for_name(name, details)
+      when true       then _default_layout(details, true)
+      when :default   then _default_layout(details, false)
+      when false, nil then nil
+      else
+        raise ArgumentError,
+          &quot;String, true, or false, expected for `layout'; you passed #{name.inspect}&quot;
+      end
+    end
+
     # Take in the name and details and find a Template.
     #
     # ==== Parameters</diff>
      <filename>actionpack/lib/abstract_controller/layouts.rb</filename>
    </modified>
    <modified>
      <diff>@@ -177,16 +177,5 @@ module ActionController
         options[:_layout] = _layout_for_option(layout, options[:_template].details)
       end
 
-      def _layout_for_option(name, details)
-        case name
-        when String     then _layout_for_name(name, details)
-        when true       then _default_layout(details, true)
-        when :default   then _default_layout(details, false)
-        when false, nil then nil
-        else
-          raise ArgumentError,
-            &quot;String, true, or false, expected for `layout'; you passed #{name.inspect}&quot;
-        end
-      end
   end
 end</diff>
      <filename>actionpack/lib/action_controller/metal/layouts.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>actionpack/lib/action_controller/legacy/layout.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f4f76772fb5c25357a54baaa9cd20f7e9a1cd653</id>
    </parent>
  </parents>
  <author>
    <name>Jos&#233; Valim</name>
    <email>jose.valim@gmail.com</email>
  </author>
  <url>http://github.com/feldpost/rails/commit/a9751a7034c5a2a49fd90e9f79ad5fcae103487b</url>
  <id>a9751a7034c5a2a49fd90e9f79ad5fcae103487b</id>
  <committed-date>2009-10-31T18:23:47-07:00</committed-date>
  <authored-date>2009-10-17T06:31:11-07:00</authored-date>
  <message>Refactor ActionMailer layout and remove legacy one.</message>
  <tree>59845a0bb38830586cbe475ec82ec50d6c545618</tree>
  <committer>
    <name>Yehuda Katz</name>
    <email>wycats@gmail.com</email>
  </committer>
</commit>
