Class: Plate::SampleTubeFactory
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Plate::SampleTubeFactory
- Defined in:
- app/models/plate/sample_tube_factory.rb
Overview
Extracted from Plate Used to convert a plate to SampleTube
Class Method Summary collapse
-
.create_sample_tubes_asset_group_and_print_barcodes(plates, barcode_printer, study) ⇒ Object
rubocop:todo Metrics/MethodLength, Metrics/AbcSize.
Instance Method Summary collapse
- #create_child_sample_tube(well) ⇒ Object
- #create_sample_tubes ⇒ Object
- #create_sample_tubes_and_print_barcodes(barcode_printer) ⇒ Object
Class Method Details
.create_sample_tubes_asset_group_and_print_barcodes(plates, barcode_printer, study) ⇒ Object
rubocop:todo Metrics/MethodLength, Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/plate/sample_tube_factory.rb', line 24 def self.(plates, , study) return nil if plates.empty? = plates.map(&:barcode_number) asset_group = AssetGroup.find_or_create_asset_group("#{.join('-')} #{Time.current.to_fs(:sortable)} ", study) plates.each do |plate| factory = Plate::SampleTubeFactory.new(plate) next if factory.wells.empty? asset_group.assets << factory.().map(&:receptacle) end return nil if asset_group.assets.empty? asset_group.save! asset_group end |
Instance Method Details
#create_child_sample_tube(well) ⇒ Object
9 10 11 12 13 |
# File 'app/models/plate/sample_tube_factory.rb', line 9 def create_child_sample_tube(well) Tube::Purpose.standard_sample_tube.create!.tap do |sample_tube| sample_tube.receptacle.transfer_requests_as_target.create!(asset: well) end end |
#create_sample_tubes ⇒ Object
5 6 7 |
# File 'app/models/plate/sample_tube_factory.rb', line 5 def create_sample_tubes wells.map { |well| create_child_sample_tube(well) } end |
#create_sample_tubes_and_print_barcodes(barcode_printer) ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/models/plate/sample_tube_factory.rb', line 15 def () sample_tubes = create_sample_tubes print_job = LabelPrinter::PrintJob.new(.name, LabelPrinter::Label::PlateToTubes, sample_tubes:) print_job.execute sample_tubes end |