Class: LabwareCreators::PooledTubesFromWholeTubes
- Includes:
- CustomPage, SupportParent::TubeOnly
- Defined in:
- app/models/labware_creators/pooled_tubes_from_whole_tubes.rb
Overview
Pools one or more source tubes into a single tube. Provides an inbox list on the left hand side of the page listing available tubes (tubes of the correct type).
Defined Under Namespace
Classes: SubmissionFailure
Instance Attribute Summary collapse
-
#barcodes ⇒ Object
Returns the value of attribute barcodes.
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#tube_transfer ⇒ Object
readonly
Returns the value of attribute tube_transfer.
Instance Method Summary collapse
-
#available_tubes ⇒ Object
TODO: This should probably be asynchronous.
- #create_labware! ⇒ Object
- #number_of_parent_labwares ⇒ Object
- #parent ⇒ Object included from SupportParent::TubeOnly
- #parents ⇒ Object
- #parents_suitable ⇒ Object
Constructor Details
This class inherits a constructor from LabwareCreators::Base
Instance Attribute Details
#barcodes ⇒ Object
Returns the value of attribute barcodes.
13 14 15 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 13 def @barcodes end |
#child ⇒ Object (readonly)
Returns the value of attribute child.
13 14 15 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 13 def child @child end |
#tube_transfer ⇒ Object (readonly)
Returns the value of attribute tube_transfer.
13 14 15 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 13 def tube_transfer @tube_transfer end |
Instance Method Details
#available_tubes ⇒ Object
TODO: This should probably be asynchronous
36 37 38 39 40 41 42 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 36 def available_tubes @search_options = OngoingTube.new(purpose_names: [parent.purpose.name], include_used: false) @search_results = Sequencescape::Api::V2::Tube.find_all( **@search_options.v2_search_parameters.merge({ includes: 'purpose', paginate: @search_options.v2_pagination }) ) end |
#create_labware! ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 20 def create_labware! # Create a single tube # TODO: This should link to multiple parents in production tc = api.tube_from_tube_creation.create!(user: user_uuid, parent: parent_uuid, child_purpose: purpose_uuid) @child = tc.child # Transfer EVERYTHING into it api.transfer_request_collection.create!(user: user_uuid, transfer_requests: transfer_request_attributes) end |
#number_of_parent_labwares ⇒ Object
57 58 59 60 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 57 def number_of_parent_labwares # default to 4 if value not found in config purpose_config.fetch(:number_of_parent_labwares, 4) end |
#parent ⇒ Object Originally defined in module SupportParent::TubeOnly
#parents ⇒ Object
44 45 46 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 44 def parents @parents ||= Sequencescape::Api::V2::Tube.find_all(barcode: , includes: []) end |
#parents_suitable ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'app/models/labware_creators/pooled_tubes_from_whole_tubes.rb', line 48 def parents_suitable # Plate#barcode =~ ensures different 'flavours' of the same barcode still match. # Ie. EAN13 encoded versions will match the Code39 encoded versions. = .reject { |scanned_bc| parents.any? { |p| p. =~ scanned_bc } } return if .empty? errors.add(:barcodes, "could not be found: #{}") end |