Module: CaTissue::StorageTypeHolder

Includes:
PartialOrder
Included in:
StorageContainer, StorageType
Defined in:
lib/catissue/util/storage_type_holder.rb

Overview

The StorageTypeHolder mix-in adds common methods for the StorageType or StorageContainer child type accessors.

Instance Method Summary collapse

Instance Method Details

#add_child_type(type) ⇒ StorageTypeHolder

Adds the given subtype to the list of subtypes which this StorageType can hold.

Parameters:

Returns:

Raises:

  • (ArgumentError)

    if the type to add is not a supported parameter



35
36
37
38
39
40
41
42
43
# File 'lib/catissue/util/storage_type_holder.rb', line 35

def add_child_type(type)
  case type
    when CaTissue::StorageType then add_storage_type(type)
    when CaTissue::SpecimenArrayType then add_specimen_array_type(type)
    when String then add_specimen_class(type)
    else raise ArgumentError.new("Storage type child not supported - #{type}")
  end
  self
end

#child_specimen_array_typesStorageType

Returns the allowable child specimen array types.

Returns:

  • (StorageType)

    the allowable child specimen array types



19
20
21
# File 'lib/catissue/util/storage_type_holder.rb', line 19

def child_specimen_array_types
  holds_specimen_array_types
end

#child_specimen_classesString

Returns the allowable child specimen classes.

Returns:

  • (String)

    the allowable child specimen classes



14
15
16
# File 'lib/catissue/util/storage_type_holder.rb', line 14

def child_specimen_classes
  holds_specimen_classes
end

#child_storage_typesStorageType

Returns the allowable child storage types.

Returns:



9
10
11
# File 'lib/catissue/util/storage_type_holder.rb', line 9

def child_storage_types
  holds_storage_types
end

#child_typesObject

Returns the CaTissue::SpecimenArrayType, AbstractSpecimen#specimen_class or CaTissue::StorageType children which this StorageTypeHolder can hold.



25
26
27
# File 'lib/catissue/util/storage_type_holder.rb', line 25

def child_types
  child_storage_types.union(child_specimen_classes).union(child_specimen_array_types)
end