Class: LabwareCreators::Base
- Inherits:
-
Object
- Object
- LabwareCreators::Base
- Extended by:
- NestedValidation
- Includes:
- Form, NoCustomPage, PlateWalking
- Defined in:
- app/models/labware_creators/base.rb
Overview
rubocop:todo Style/Documentation
Direct Known Subclasses
CardinalPoolsPlate, CustomTaggedPlate, DonorPoolingPlate, FinalTube, FinalTubeFromPlate, MultiPlatePool, MultiStamp, MultiStampTubes, MultiStampTubesUsingTubeRackScan, PlateSplitToTubeRacks, PlateWithTemplate, PooledTubesBase, PooledTubesFromWholePlates, PooledTubesFromWholeTubes, PooledWellsBySampleInGroups, StampedPlate, TaggedPlate, TubeFromTube, Uncreatable
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#params ⇒ Object
Returns the value of attribute params.
-
#parent_uuid ⇒ Object
Returns the value of attribute parent_uuid.
-
#purpose_uuid ⇒ Object
Returns the value of attribute purpose_uuid.
-
#user_uuid ⇒ Object
Returns the value of attribute user_uuid.
Class Method Summary collapse
-
.support_parent?(_parent) ⇒ Boolean
The base creator is abstract, and is not intended to be used directly.
-
.validates_nested(*attr_names) ⇒ NestedValidator
extended
from NestedValidation
Records of this class will call valid? on any associations provided as attr_names.
Instance Method Summary collapse
- #anchor ⇒ Object
-
#initialize(api, *args) ⇒ Base
constructor
We pull out the api as the first argument as it ensures we’ll always have it available, even during assignment of other attributes.
- #labware ⇒ Object
- #persisted? ⇒ Boolean included from Form
- #plate_to_walk ⇒ Object
-
#purpose_name ⇒ String
The name of the child purpose.
-
#redirection_target ⇒ Object
The object which we cant to redirect the user to after the creator has been saved.
- #save ⇒ Object
- #save! ⇒ Object
-
#transfer_template_name ⇒ <String] The name of the transfer template which will be used.
The name of the transfer template which will be used.
-
#transfer_template_uuid ⇒ String
The uuid of the transfer template to be used.
- #wells_by_row ⇒ Object included from PlateWalking
Constructor Details
#initialize(api, *args) ⇒ Base
We pull out the api as the first argument as it ensures we’ll always have it available, even during assignment of other attributes. Otherwise we end up relying on hash order.
38 39 40 41 |
# File 'app/models/labware_creators/base.rb', line 38 def initialize(api, *args) @api = api super(*args) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
16 17 18 |
# File 'app/models/labware_creators/base.rb', line 16 def api @api end |
#child ⇒ Object (readonly)
Returns the value of attribute child.
16 17 18 |
# File 'app/models/labware_creators/base.rb', line 16 def child @child end |
#params ⇒ Object
Returns the value of attribute params.
17 18 19 |
# File 'app/models/labware_creators/base.rb', line 17 def params @params end |
#parent_uuid ⇒ Object
Returns the value of attribute parent_uuid.
17 18 19 |
# File 'app/models/labware_creators/base.rb', line 17 def parent_uuid @parent_uuid end |
#purpose_uuid ⇒ Object
Returns the value of attribute purpose_uuid.
17 18 19 |
# File 'app/models/labware_creators/base.rb', line 17 def purpose_uuid @purpose_uuid end |
#user_uuid ⇒ Object
Returns the value of attribute user_uuid.
17 18 19 |
# File 'app/models/labware_creators/base.rb', line 17 def user_uuid @user_uuid end |
Class Method Details
.support_parent?(_parent) ⇒ Boolean
The base creator is abstract, and is not intended to be used directly
31 32 33 |
# File 'app/models/labware_creators/base.rb', line 31 def self.support_parent?(_parent) false end |
.validates_nested(*attr_names) ⇒ NestedValidator Originally defined in module NestedValidation
Records of this class will call valid? on any associations provided as attr_names. Errors on these records will be propagated out
Instance Method Details
#anchor ⇒ Object
91 92 93 |
# File 'app/models/labware_creators/base.rb', line 91 def anchor 'summary_tab' end |
#labware ⇒ Object
47 48 49 |
# File 'app/models/labware_creators/base.rb', line 47 def labware parent end |
#persisted? ⇒ Boolean Originally defined in module Form
#plate_to_walk ⇒ Object
43 44 45 |
# File 'app/models/labware_creators/base.rb', line 43 def plate_to_walk parent end |
#purpose_name ⇒ String
The name of the child purpose.
100 101 102 |
# File 'app/models/labware_creators/base.rb', line 100 def purpose_name purpose_config.name end |
#redirection_target ⇒ Object
The object which we cant to redirect the user to after the creator has been saved. If you’ve created a single entity, this should probably be the child, so that’s what we return by default
87 88 89 |
# File 'app/models/labware_creators/base.rb', line 87 def redirection_target child end |
#save ⇒ Object
55 56 57 |
# File 'app/models/labware_creators/base.rb', line 55 def save valid? && create_labware! end |
#save! ⇒ Object
51 52 53 |
# File 'app/models/labware_creators/base.rb', line 51 def save! save || raise(ResourceInvalid, self) end |
#transfer_template_name ⇒ <String] The name of the transfer template which will be used.
The name of the transfer template which will be used. In post cases this will be the default transfer template but it can be overridden by specifying a custom template in the purpose config.
67 68 69 |
# File 'app/models/labware_creators/base.rb', line 67 def transfer_template_name purpose_config.fetch(:transfer_template, default_transfer_template_name) end |
#transfer_template_uuid ⇒ String
The uuid of the transfer template to be used. Extracted from the transfer template cache base on the name
77 78 79 |
# File 'app/models/labware_creators/base.rb', line 77 def transfer_template_uuid Settings.transfer_templates.fetch(transfer_template_name) end |