From 67cc07e0c4bd071dd3d2f4098e5a4c31ba590684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 8 Dec 2011 16:51:47 +0100 Subject: Just use the proc if there is a chance of layout lookup. --- actionpack/lib/abstract_controller/layouts.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index 6b6b38c64f..8356d822da 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -293,7 +293,7 @@ module AbstractController 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 @@ -323,9 +323,10 @@ module AbstractController # * name - 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, @@ -358,7 +359,7 @@ module AbstractController "There was no default layout for #{self.class} in #{view_paths.inspect}" end - value + _normalize_layout(value) end def _include_layout?(options) -- cgit v1.2.3