Class: Equipment

Inherits:
ApplicationRecord show all
Defined in:
app/models/equipment.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#barcode_numberObject


15
16
17
# File 'app/models/equipment.rb', line 15

def barcode_number
  Barcode.number_to_human(self.ean13_barcode)
end

#set_defaultsObject


6
7
8
# File 'app/models/equipment.rb', line 6

def set_defaults
  self.prefix ||= 'XX'
end

#suffixObject


19
20
21
# File 'app/models/equipment.rb', line 19

def suffix
  Barcode.calculate_checksum(prefix, barcode_number)
end

#update_barcodeObject


10
11
12
13
# File 'app/models/equipment.rb', line 10

def update_barcode
  self.ean13_barcode ||= Barcode.calculate_barcode(prefix, id)
  save!
end