Class: Equipment

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

Overview

A table allowing for the generation of unique equipment barcodes. Seems to perform an almost identical function to the unused Implement. No dependencies in the rest of the code, and mainly just used to ensure uniqueness of equipment barcodes.

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 Squishify

extended

Methods included from Warren::BroadcastMessages

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

Instance Method Details

#barcode_numberObject


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

def barcode_number
  Barcode.number_to_human(self.ean13_barcode)
end

#set_defaultsObject


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

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

#suffixObject


23
24
25
# File 'app/models/equipment.rb', line 23

def suffix
  Barcode.calculate_checksum(prefix, barcode_number)
end

#update_barcodeObject


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

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