Sha256: 8f55017bb14fe1196d97b827cd0c748f4331326e533b4dc8155c1123984cc4fe

Contents?: true

Size: 626 Bytes

Versions: 17

Compression:

Stored size: 626 Bytes

Contents

module Refinery
  module Pages
    class Types < Array

      def register(name, &block)
        self.class.register(name, &block)
      end

      def find_by_name(name)
        detect {|type| type.name.to_s.downcase == name.to_s.downcase}
      end

      class << self
        def register(name, &block)
          type = Type.new
          type.name = name

          yield type if block_given?

          raise "A page type must have a name: #{self.inspect}" if type.name.blank?

          registered << type
        end

        def registered
          @registered_types ||= new
        end
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
refinerycms-pages-2.1.5 lib/refinery/pages/types.rb
refinerycms-pages-2.1.4 lib/refinery/pages/types.rb
refinerycms-pages-2.1.3 lib/refinery/pages/types.rb
refinerycms-pages-2.1.2 lib/refinery/pages/types.rb
refinerycms-pages-2.1.1 lib/refinery/pages/types.rb
refinerycms-pages-2.1.0 lib/refinery/pages/types.rb
refinerycms-pages-2.0.10 lib/refinery/pages/types.rb
refinerycms-pages-2.0.9 lib/refinery/pages/types.rb
refinerycms-pages-2.0.8 lib/refinery/pages/types.rb
refinerycms-pages-2.0.7 lib/refinery/pages/types.rb
refinerycms-pages-2.0.6 lib/refinery/pages/types.rb
refinerycms-pages-2.0.5 lib/refinery/pages/types.rb
refinerycms-pages-2.0.4 lib/refinery/pages/types.rb
refinerycms-pages-2.0.3 lib/refinery/pages/types.rb
refinerycms-pages-2.0.2 lib/refinery/pages/types.rb
refinerycms-pages-2.0.1 lib/refinery/pages/types.rb
refinerycms-pages-2.0.0 lib/refinery/pages/types.rb