Class: SequencescapeExcel::SpecialisedField::SangerPlateId
- Inherits:
-
Object
- Object
- SequencescapeExcel::SpecialisedField::SangerPlateId
- Includes:
- Base, ValueRequired
- Defined in:
- app/sequencescape_excel/sequencescape_excel/specialised_field/sanger_plate_id.rb
Overview
A required field if it is a plate manifest. Checked to ensure that it is the same as the sanger human barcode for sample, or is a valid foreign barcode. Updated if there is a valid foreign barcode.
Instance Attribute Summary collapse
-
#foreign_barcode_format ⇒ Object
readonly
Returns the value of attribute foreign_barcode_format.
Attributes included from Base
#sample_manifest_asset, #value
Instance Method Summary collapse
-
#update(_attributes = {}) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity, Metrics/AbcSize.
Methods included from Base
Instance Attribute Details
#foreign_barcode_format ⇒ Object (readonly)
Returns the value of attribute foreign_barcode_format.
14 15 16 |
# File 'app/sequencescape_excel/sequencescape_excel/specialised_field/sanger_plate_id.rb', line 14 def @foreign_barcode_format end |
Instance Method Details
#update(_attributes = {}) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity, Metrics/AbcSize
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/sequencescape_excel/sequencescape_excel/specialised_field/sanger_plate_id.rb', line 19 def update(_attributes = {}) # rubocop:todo Metrics/CyclomaticComplexity, Metrics/MethodLength return unless valid? && .present? # checking if the plate this well belongs to already has this foreign barcode set in its list of barcodes. # or if it contains a foreign barcode with the same format, then update that existing one = asset.plate..find { |item| item[:format] == .to_s } if .present? if . != value .update(barcode: value) sample_manifest. if sample_manifest.present? end else asset.plate. << Barcode.new(format: , barcode: value) sample_manifest. if sample_manifest.present? end end |