Module: CaTissue::StorageTypeHolder

Includes:
Jinx::PartialOrder
Included in:
StorageContainer, StorageType
Defined in:
lib/catissue/helpers/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



41
42
43
44
45
46
47
48
49
# File 'lib/catissue/helpers/storage_type_holder.rb', line 41

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_container_typesObject

Returns the CaTissue::SpecimenArrayType or CaTissue::StorageType children which this StorageTypeHolder can hold.



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

def child_container_types
  @ccts ||= child_storage_types.union(child_specimen_array_types)
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/helpers/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/helpers/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/helpers/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.



31
32
33
# File 'lib/catissue/helpers/storage_type_holder.rb', line 31

def child_types
  @cts ||= child_container_types.union(child_specimen_classes)
end