Sha256: d5cf44d14964adea12a547851c898530f6e71d251439e906980b14f6c4d7ed8b

Contents?: true

Size: 627 Bytes

Versions: 11

Compression:

Stored size: 627 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

11 entries across 11 versions & 1 rubygems

Version Path
refinerycms-pages-4.0.3 lib/refinery/pages/types.rb
refinerycms-pages-4.0.2 lib/refinery/pages/types.rb
refinerycms-pages-4.0.1 lib/refinery/pages/types.rb
refinerycms-pages-3.0.6 lib/refinery/pages/types.rb
refinerycms-pages-4.0.0 lib/refinery/pages/types.rb
refinerycms-pages-3.0.5 lib/refinery/pages/types.rb
refinerycms-pages-3.0.4 lib/refinery/pages/types.rb
refinerycms-pages-3.0.3 lib/refinery/pages/types.rb
refinerycms-pages-3.0.2 lib/refinery/pages/types.rb
refinerycms-pages-3.0.1 lib/refinery/pages/types.rb
refinerycms-pages-3.0.0 lib/refinery/pages/types.rb