Sha256: c43b230e06c3d8b04126208adb1f2eabc78ee70bf24e8db1662c4cfc90c49798

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

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

module CanTango
  class Configuration
    class Registry
      attr_writer   :default
      attr_accessor :registered

      include Singleton

      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 default
        @default ||= []
      end
    end
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 lib/cantango/configuration/registry.rb