Sha256: 93de27421acc89fe977ecd85a804feb16523bef1c4a807d2d706e38f90943ceb

Contents?: true

Size: 918 Bytes

Versions: 20

Compression:

Stored size: 918 Bytes

Contents

require 'singleton'
require 'sugar-high/kind_of'

module CanTango
  class Configuration
    class Registry

      attr_writer   :default
      attr_accessor :registered

      def types= *types
        @types = types.select {|t| t.is_a? Class }
      end

      def types
        @types ||= [Symbol, String]
        @types
      end

      def clean!
        @registered = []
      end

      alias_method :clear!, :clean!

      def default!
        @registered = default
      end

      def register *list
        registered << list.select_kinds_of(*types)
        registered.flat_uniq!
      end

      alias_method :<<, :register

      def [] index
        registered[index]
      end

      def registered
        @registered ||= default
      end

      def registered? label
        registered.map(&:to_s).include? label.to_s
      end

      def default
        @default ||= []
      end
    end
  end
end


Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/configuration/registry.rb
cantango-0.9.4.6 lib/cantango/configuration/registry.rb
cantango-0.9.4.5 lib/cantango/configuration/registry.rb
cantango-0.9.4.3 lib/cantango/configuration/registry.rb
cantango-0.9.4.2 lib/cantango/configuration/registry.rb
cantango-0.9.4.1 lib/cantango/configuration/registry.rb
cantango-0.9.4 lib/cantango/configuration/registry.rb
cantango-0.9.3.2 lib/cantango/configuration/registry.rb
cantango-0.8.9.5 lib/cantango/configuration/registry.rb
cantango-0.8.9.4 lib/cantango/configuration/registry.rb
cantango-0.8.9.3 lib/cantango/configuration/registry.rb
cantango-0.8.9.2 lib/cantango/configuration/registry.rb
cantango-0.8.9.1 lib/cantango/configuration/registry.rb
cantango-0.8.9 lib/cantango/configuration/registry.rb
cantango-0.8.8.1 lib/cantango/configuration/registry.rb
cantango-0.8.8 lib/cantango/configuration/registry.rb
cantango-0.8.7 lib/cantango/configuration/registry.rb
cantango-0.8.6.2 lib/cantango/configuration/registry.rb
cantango-0.8.6.1 lib/cantango/configuration/registry.rb
cantango-0.8.6 lib/cantango/configuration/registry.rb