Sha256: f47a74e6f461bf535df81e825db2252a0a41e59687109966b2e4851f272c693a

Contents?: true

Size: 1018 Bytes

Versions: 8

Compression:

Stored size: 1018 Bytes

Contents

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

module CanTango
  class Configuration
    class CandidateRegistry
      def register name, clazz
        raise "first arg must be a label" if !name.kind_of_label?
        raise "second arg must be a Class" if !clazz.kind_of? Class
        name_registry.register name.to_sym
        class_registry.register clazz
      end

      def registered
        name_registry.registered
      end

      def registered_classes
        class_registry.registered
      end

      def registered? name
        name_registry.registered? name
      end

      def registered_class? name
        class_registry.registered? name
      end

      def name_registry
        NameRegistry.instance
      end

      def class_registry
        ClassRegistry.instance
      end

      class NameRegistry < Registry
        include Singleton
      end

      class ClassRegistry < Registry
        include Singleton

        def types
          [Class]
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4.6 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4.5 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4.3 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4.2 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4.1 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.4 lib/cantango/configuration/candidate_registry.rb
cantango-0.9.3.2 lib/cantango/configuration/candidate_registry.rb