Class: UatActions::GenerateTubeRacks

Inherits:
UatActions show all
Defined in:
app/uat_actions/uat_actions/generate_tube_racks.rb

Overview

Will construct tube racks with sample tubes filled with samples

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UatActions

all, find, form_field, form_fields, #form_fields, id, inherited, permitted, #report, #save, to_partial_path, uat_actions

Class Method Details

.defaultObject


22
23
24
# File 'app/uat_actions/uat_actions/generate_tube_racks.rb', line 22

def self.default
  new(rack_count: 1, study_name: UatActions::StaticRecords.study.name)
end

Instance Method Details

#performObject

rubocop:todo Metrics/AbcSize


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/uat_actions/uat_actions/generate_tube_racks.rb', line 26

def perform # rubocop:todo Metrics/AbcSize
  purpose = Purpose.find_by(name: 'TR Stock 96')
  rack_count.to_i.times do |i|
    TubeRack
      .create!(size: 96, purpose: purpose)
      .tap do |rack|
        Barcode.create!(
          asset: rack,
          barcode: "AB#{Time.zone.now.hash.abs.to_s.slice(0, 8)}",
          format: 'fluidx_barcode'
        )
        construct_tubes(rack)
        report["rack_#{i}"] = rack.human_barcode
      end
  end
  true
end