Sha256: 356caea1d211e715d67d8fc0aadab24f279c038ed2f86b14dda322d6b415522c

Contents?: true

Size: 905 Bytes

Versions: 27

Compression:

Stored size: 905 Bytes

Contents

module Hanami
  module View
    module Rendering
      # Find a view
      #
      # @api private
      # @since 0.1.0
      #
      # @see Hanami::View::Rendering::Registry
      class ViewFinder
        # Initialize a finder
        #
        # @param view [Class] the superclass view
        #
        # @api private
        # @since 0.1.0
        def initialize(view)
          @view = view
        end

        # Find a view for the given template.
        # It looks up for the current view and its subclasses.
        #
        # @param template [Hanami::View::Template] a template to be associated
        #   to a view
        #
        # @return [Class] a view associated with the given template
        #
        # @api private
        # @since 0.1.0
        def find(template)
          @view.subclasses.find {|v| v.format == template.format } || @view
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
hanami-view-1.0.0.rc1 lib/hanami/view/rendering/view_finder.rb
hanami-view-1.0.0.beta2 lib/hanami/view/rendering/view_finder.rb
hanami-view-1.0.0.beta1 lib/hanami/view/rendering/view_finder.rb
hanami-view-0.8.0 lib/hanami/view/rendering/view_finder.rb
hanami-view-0.7.0 lib/hanami/view/rendering/view_finder.rb
hanami-view-0.6.1 lib/hanami/view/rendering/view_finder.rb
hanami-view-0.6.0 lib/hanami/view/rendering/view_finder.rb