Sha256: 9809e2c058d08fbf503f63a6b7b68f52cce99d43c136e805ac6f222040b3336e

Contents?: true

Size: 707 Bytes

Versions: 9

Compression:

Stored size: 707 Bytes

Contents

module Pageflow
  class PageTypes
    include Enumerable

    def initialize
      clear
    end

    def clear
      @page_types = []
      @page_types_by_name = {}
    end

    def register(page_type)
      @page_types << page_type
      @page_types_by_name[page_type.name] = page_type

      ensure_export_version_implemented(page_type)
    end

    def find_by_name!(name)
      @page_types_by_name.fetch(name) do
        raise "Unknown page type with name #{name}."
      end
    end

    def names
      map(&:name)
    end

    def each(&block)
      @page_types.each(&block)
    end

    private

    def ensure_export_version_implemented(page_type)
      page_type.export_version
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pageflow-15.1.0.beta2 lib/pageflow/page_types.rb
pageflow-15.1.0.beta1 lib/pageflow/page_types.rb
pageflow-15.0.2 lib/pageflow/page_types.rb
pageflow-15.0.1 lib/pageflow/page_types.rb
pageflow-15.0.0 lib/pageflow/page_types.rb
pageflow-15.0.0.rc2 lib/pageflow/page_types.rb
pageflow-15.0.0.rc1 lib/pageflow/page_types.rb
pageflow-15.0.0.beta4 lib/pageflow/page_types.rb
pageflow-15.0.0.beta3 lib/pageflow/page_types.rb