Class: CaTissue::StorageType
- Inherits:
-
Object
- Object
- CaTissue::StorageType
- Includes:
- HashCode, Resource, StorageTypeHolder, PartialOrder
- Defined in:
- lib/catissue/domain/storage_type.rb
Overview
The StorageType domain class.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Returns -1, 0, or 1 if self is contained in, contains or the same as the other StorageType, resp.
-
#==(other) ⇒ Object
(also: #eql?)
This method is a work-around for caTissue Bug #70: StorageType and non-StorageType are equal.
-
#can_hold_child?(storable) ⇒ Boolean
Whether this StorageType can hold a child of the given Storable storable type.
-
#closure ⇒ Object
The closure of ContainerTypes held by this ContainerType, including self.
-
#container_class ⇒ Object
StorageContainer.
-
#path_to(storable) ⇒ Object
Returns a StorageType array from this StorageType to a descendant StorageType which can hold the given storable, or nil if no such path exists.
Methods included from StorageTypeHolder
#add_child_type, #child_specimen_array_types, #child_specimen_classes, #child_storage_types, #child_types
Methods included from Resource
#database, included, #tolerant_match?
Methods included from Annotatable
#annotation_proxy, #create_proxy, #method_missing
Methods included from HashCode
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CaTissue::Annotatable
Instance Method Details
#<=>(other) ⇒ Object
Returns -1, 0, or 1 if self is contained in, contains or the same as the other StorageType, resp.
68 69 70 71 72 73 |
# File 'lib/catissue/domain/storage_type.rb', line 68 def <=>(other) raise TypeError.new("Can't compare #{qp} to #{other}") unless StorageType === self return 0 if eql?(other) return 1 if holds_storage_types.detect { |child| child >= other } -1 if other > self end |
#==(other) ⇒ Object Also known as: eql?
This method is a work-around for caTissue Bug #70: StorageType and non-StorageType are equal.
60 61 62 |
# File 'lib/catissue/domain/storage_type.rb', line 60 def ==(other) equal?(other) or (StorageType === other and name and name == other.name) end |
#can_hold_child?(storable) ⇒ Boolean
Returns whether this StorageType can hold a child of the given Storable storable type.
38 39 40 |
# File 'lib/catissue/domain/storage_type.rb', line 38 def can_hold_child?(storable) child_types.include?(storable.storable_type) end |
#closure ⇒ Object
Returns the closure of ContainerTypes held by this ContainerType, including self.
51 52 53 54 55 |
# File 'lib/catissue/domain/storage_type.rb', line 51 def closure cts = [self] child_types.each { |ct| cts.concat(ct.closure) if StorageType === ct } cts end |
#container_class ⇒ Object
Returns StorageContainer.
27 28 29 |
# File 'lib/catissue/domain/storage_type.rb', line 27 def container_class CaTissue::StorageContainer end |
#path_to(storable) ⇒ Object
Returns a StorageType array from this StorageType to a descendant StorageType which can hold the given storable, or nil if no such path exists.
44 45 46 47 48 |
# File 'lib/catissue/domain/storage_type.rb', line 44 def path_to(storable) return [self] if can_hold_child?(storable) path = holds_storage_types.detect_value { |child| child.path_to(storable) } return path.unshift(self) if path end |