Sha256: 6894d2744002748e363dc4ab2210b2b65e878786d2c20a21b73aff7bcb2eb447

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

module TypeCollection
  module Base
    
    module BaseClassMethods
      # Returns all of the known subclass names for this collection
      def all_type_names(); return __tc_members().keys(); end
      # Returns all of the known subclasses for this collection
      def all_types(); return __tc_members().values(); end
      # Gets the type associated with the provided value (Class or Otherwise)
      def get_type(type)
        type = type.inferred_type() if (type.kind_of?(Class))
        mems = __tc_members()
        raise TypeCollection::UnknownChildType.new() unless (mems.has_key?(type))
        return mems[type]
      end
    end
    
    def self.included(base)
      base.extend(TypeCollection::ClassMethods)
      base.extend(TypeCollection::Base::BaseClassMethods)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typecollection-0.0.3 lib/typecollection/base.rb