Class: Hanami::View::Rendering::LayoutFinder Private
- Inherits:
-
Object
- Object
- Hanami::View::Rendering::LayoutFinder
- Defined in:
- lib/hanami/view/rendering/layout_finder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defines the logic to find a layout
Constant Summary collapse
- SUFFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Layout class name suffix
'Layout'.freeze
Class Method Summary collapse
-
.find(layout, namespace = Object) ⇒ Hanami::Layout
private
Find a layout from the given name.
Instance Method Summary collapse
-
#find ⇒ Hanami::Layout
private
Find the layout for the view.
-
#initialize(view) ⇒ LayoutFinder
constructor
private
Initialize the finder.
Constructor Details
#initialize(view) ⇒ LayoutFinder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the finder
82 83 84 |
# File 'lib/hanami/view/rendering/layout_finder.rb', line 82 def initialize(view) @view = view end |
Class Method Details
.find(layout, namespace = Object) ⇒ Hanami::Layout
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find a layout from the given name.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hanami/view/rendering/layout_finder.rb', line 64 def self.find(layout, namespace = Object) case layout when Symbol, String # TODO Move this low level logic into a Hanami::Utils solution class_name = "#{ Utils::String.classify(layout) }#{ SUFFIX }" namespace = Utils::Class.load!(namespace) namespace.const_get(class_name) when Class layout end || NullLayout end |
Instance Method Details
#find ⇒ Hanami::Layout
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find the layout for the view
122 123 124 |
# File 'lib/hanami/view/rendering/layout_finder.rb', line 122 def find self.class.find(@view.layout) end |