Class: Hanami::View::Rendering::LayoutRegistry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/view/rendering/layout_registry.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.

Holds the references of all the registered layouts. As now the registry is unique at the level of the framework.

See Also:

Since:

  • 0.1.0

Direct Known Subclasses

Registry

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ LayoutRegistry

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 registry

Parameters:

  • view (Class)

    the view

Since:

  • 0.1.0



21
22
23
24
25
# File 'lib/hanami/view/rendering/layout_registry.rb', line 21

def initialize(view)
  @registry = {}
  @view = view
  prepare!
end

Instance Method Details

#resolve(context) ⇒ Hanami::Layout, Hanami::View::Rendering::NullTemplate

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.

Returns the layout for the given context.

Parameters:

  • context (Hash)

    the rendering context

Options Hash (context):

  • :format (Symbol)

    the requested format

Returns:

Raises:

Since:

  • 0.1.0



41
42
43
# File 'lib/hanami/view/rendering/layout_registry.rb', line 41

def resolve(context)
  @registry.fetch(format(context)) { NullTemplate.new }
end