Skip to content

Commit

Permalink
Just use the proc if there is a chance of layout lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 8, 2011
1 parent 239262f commit 67cc07e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions actionpack/lib/abstract_controller/layouts.rb
Expand Up @@ -293,7 +293,7 @@ def _normalize_options(options)

if _include_layout?(options)
layout = options.key?(:layout) ? options.delete(:layout) : :default
options[:layout] = Proc.new { _normalize_layout(_layout_for_option(layout)) }
options[:layout] = _layout_for_option(layout)
end
end

Expand Down Expand Up @@ -323,9 +323,10 @@ def _layout; end
# * <tt>name</tt> - The name of the template
def _layout_for_option(name)
case name
when String then name
when true then _default_layout(true)
when :default then _default_layout(false)
when String then _normalize_layout(name)
when Proc then name
when true then Proc.new { _default_layout(true) }
when :default then Proc.new { _default_layout(false) }
when false, nil then nil
else
raise ArgumentError,
Expand Down Expand Up @@ -358,7 +359,7 @@ def _default_layout(require_layout = false)
"There was no default layout for #{self.class} in #{view_paths.inspect}"
end

value
_normalize_layout(value)
end

def _include_layout?(options)
Expand Down

0 comments on commit 67cc07e

Please sign in to comment.