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

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#barcode_numberObject



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

def barcode_number
  Barcode.number_to_human(self.ean13_barcode)
end

#set_defaultsObject



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

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

#suffixObject



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

def suffix
  Barcode.calculate_checksum(prefix, barcode_number)
end

#update_barcodeObject



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

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