Class: SpecificTubeCreation
- Inherits:
-
TubeCreation
- Object
- ActiveRecord::Base
- ApplicationRecord
- AssetCreation
- TubeCreation
- SpecificTubeCreation
- 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
-
#tube_attributes ⇒ Object
If no tube attributes are specified, fall back to an array of empty hashes.
Instance Method Summary collapse
- #multiple_purposes ⇒ Object
-
#parent ⇒ Object
singular ‘parent’ getter to stay backwards compatible.
-
#parent=(parent) ⇒ Object
singular ‘parent’ setter to stay backwards compatible.
- #set_child_purposes=(uuids) ⇒ Object
Methods inherited from AssetCreation
Methods included from Asset::Ownership::ChangesOwner
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
Instance Attribute Details
#tube_attributes ⇒ Object
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_purposes ⇒ Object
47 48 49 |
# File 'app/models/specific_tube_creation.rb', line 47 def multiple_purposes true end |
#parent ⇒ Object
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 |