Sha256: 3392d8b4d299d8091e33dc80b5b45fcd5e6c838cc8e7b645b7cc4b99c3abae23
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
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 # Get similar type based on the object passed in which can be a String, # Object (using the inferred type), or Class def get_associated_type(associate) if (!associate.kind_of?(String)) if (!associate.kind_of?(Class)) associate = associate.class end associate = associate.inferred_type() end return self.get_type(associate) end end def self.included(base) base.extend(TypeCollection::ClassMethods) base.extend(TypeCollection::Base::BaseClassMethods) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
typecollection-0.0.8 | lib/typecollection/base.rb |
typecollection-0.0.7 | lib/typecollection/base.rb |