Class: QcableCreator

Inherits:
ApplicationRecord show all
Includes:
Uuid::Uuidable
Defined in:
app/models/qcable_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Attribute Details

#barcodesObject

Returns the value of attribute barcodes.



12
13
14
# File 'app/models/qcable_creator.rb', line 12

def barcodes
  @barcodes
end

#countObject

Returns the value of attribute count.



12
13
14
# File 'app/models/qcable_creator.rb', line 12

def count
  @count
end

#supplied_barcodeObject

Returns the value of attribute supplied_barcode.



12
13
14
# File 'app/models/qcable_creator.rb', line 12

def supplied_barcode
  @supplied_barcode
end

Instance Method Details

#make_qcables!Object



16
17
18
19
20
# File 'app/models/qcable_creator.rb', line 16

def make_qcables!
  return qcables_by_supplied_barcode! if supplied_barcode.present?
  qcables_by_count! if count.present?
  qcables_by_barcode! if barcodes.present?
end

#qcables_by_barcode!Object



26
27
28
# File 'app/models/qcable_creator.rb', line 26

def qcables_by_barcode!
  barcodes.split(',').collect { |barcode| lot.qcables.create!(qcable_creator: self, barcode: barcode) }
end

#qcables_by_count!Object



22
23
24
# File 'app/models/qcable_creator.rb', line 22

def qcables_by_count!
  lot.qcables.build([{ qcable_creator: self }] * count).tap { |_| lot.save! }
end

#qcables_by_supplied_barcode!Object

Creates using the supplied plate barcode we received from baracoda



31
32
33
# File 'app/models/qcable_creator.rb', line 31

def qcables_by_supplied_barcode!
  lot.qcables.create!(qcable_creator: self, supplied_barcode: supplied_barcode)
end