Class: SpecificTubeCreation

Inherits:
TubeCreation show all
Defined in:
app/models/specific_tube_creation.rb

Overview

Allows a different purpose to be set for each of the child tubes.

Defined Under Namespace

Classes: ChildPurpose

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AssetCreation

#create_ancestor_asset!

Methods included from Asset::Ownership::ChangesOwner

included

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Attribute Details

#tube_attributesObject

If no tube attributes are specified, fall back to an array of empty hashes



52
53
54
# File 'app/models/specific_tube_creation.rb', line 52

def tube_attributes
  @tube_attributes || Array.new(child_purposes.length, {})
end

Instance Method Details

#multiple_purposesObject



47
48
49
# File 'app/models/specific_tube_creation.rb', line 47

def multiple_purposes
  true
end

#parentObject

singular ‘parent’ getter to stay backwards compatible



34
35
36
# File 'app/models/specific_tube_creation.rb', line 34

def parent
  parents.first
end

#parent=(parent) ⇒ Object

singular ‘parent’ setter to stay backwards compatible



39
40
41
# File 'app/models/specific_tube_creation.rb', line 39

def parent=(parent)
  self.parents = [parent]
end

#set_child_purposes=(uuids) ⇒ Object



43
44
45
# File 'app/models/specific_tube_creation.rb', line 43

def set_child_purposes=(uuids)
  self.child_purposes = uuids.map { |uuid| Uuid.find_by(external_id: uuid).resource }
end