module AbstractController::Layouts
def _default_layout(require_layout = false)
==== Returns
found (defaults to false)
with details about the fact that the exception could not be
* require_logout - If this is true, raise an ArgumentError
might include details like the format or locale of the template.
* details - A list of details to restrict the search by. This
==== Parameters
Optionally raises an exception if the layout could not be found.
Returns the default layout for this controller and a given set of details.
def _default_layout(require_layout = false) begin layout_name = _layout if action_has_layout? rescue NameError => e raise NoMethodError, "You specified #{@_layout.inspect} as the layout, but no such method was found" end if require_layout && action_has_layout? && !layout_name raise ArgumentError, "There was no default layout for #{self.class} in #{view_paths.inspect}" end layout_name end
def _include_layout?(options)
def _include_layout?(options) (options.keys & [:text, :inline, :partial]).empty? || options.key?(:layout) end
def _layout; end
def _layout; end
def _layout_for_option(name)
the lookup to. By default, layout lookup is limited to the
* details - A list of details to restrict
* name - The name of the template
==== Parameters
the name type.
Determine the layout for a given name and details, taking into account
def _layout_for_option(name) case name when String then name when true then _default_layout(true) when :default then _default_layout(false) when false, nil then nil else raise ArgumentError, "String, true, or false, expected for `layout'; you passed #{name.inspect}" end end
def _normalize_options(options)
def _normalize_options(options) super if _include_layout?(options) layout = options.key?(:layout) ? options.delete(:layout) : :default value = _layout_for_option(layout) options[:layout] = (value =~ /\blayouts/ ? value : "layouts/#{value}") if value end end
def action_has_layout?
def action_has_layout? @action_has_layout end
def initialize(*)
def initialize(*) @action_has_layout = true super end