Class: Hanami::View::Rendering::ViewFinder Private

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

Find a view

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ ViewFinder

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 a finder

Parameters:

  • view (Class)

    the superclass view

Since:

  • 0.1.0



17
18
19
# File 'lib/hanami/view/rendering/view_finder.rb', line 17

def initialize(view)
  @view = view
end

Instance Method Details

#find(template) ⇒ Class

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 view for the given template. It looks up for the current view and its subclasses.

Parameters:

Returns:

  • (Class)

    a view associated with the given template

Since:

  • 0.1.0



31
32
33
# File 'lib/hanami/view/rendering/view_finder.rb', line 31

def find(template)
  @view.subclasses.find {|v| v.format == template.format } || @view
end