Sha256: 85d0d02059cfbbd6a242b280c93aacf74e1e38943d5e616d72f60de91ce7b748

Contents?: true

Size: 902 Bytes

Versions: 9

Compression:

Stored size: 902 Bytes

Contents

module Lotus
  module View
    module Rendering
      # Find a view
      #
      # @api private
      # @since 0.1.0
      #
      # @see Lotus::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 [Lotus::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

9 entries across 9 versions & 1 rubygems

Version Path
lotus-view-0.5.0 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.4.4 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.4.3 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.4.2 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.4.1 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.4.0 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.3.0 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.2.0 lib/lotus/view/rendering/view_finder.rb
lotus-view-0.1.0 lib/lotus/view/rendering/view_finder.rb