Sha256: f6fd44e81bda38a8c56df80cb0a3bd1309c5da5468a6b80264a08da834efa44e
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 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("Unregistered type: #{type}") 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
typecollection-0.0.10 | lib/typecollection/base.rb |