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

Constant Summary

Constants inherited from UatActions

CATEGORY_LIST

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UatActions

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

Class Method Details

.defaultObject



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

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

Instance Method Details

#performObject

rubocop:todo Metrics/AbcSize, Metrics/MethodLength



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

def perform # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
  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