Module: SampleManifest::BarcodePrinterBehaviour

Included in:
SampleManifest
Defined in:
app/models/sample_manifest/barcode_printer_behaviour.rb

Constant Summary collapse

ASSET_TYPE_TO_PRINTER_TYPE =
{
  '1dtube' => [BarcodePrinterType1DTube],
  'plate' => [BarcodePrinterType96Plate, BarcodePrinterType384DoublePlate]
}.freeze

Instance Method Summary collapse

Instance Method Details

#applicable_barcode_printersObject

rubocop:todo Metrics/MethodLength



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/sample_manifest/barcode_printer_behaviour.rb', line 8

def applicable_barcode_printers # rubocop:todo Metrics/MethodLength
  printer_type_classes = ASSET_TYPE_TO_PRINTER_TYPE[asset_type]
  printers = []
  if printer_type_classes.nil?
    printers += BarcodePrinter.alphabetical
  else
    printer_type_classes.each do |printer_type_class|
      BarcodePrinterType
        .where(type: printer_type_class)
        .find_each { |printer_type| printers += printer_type.barcode_printers unless printer_type.nil? }
    end
  end
  printers
end