Class: Implement Deprecated

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

Overview

Deprecated.

This class doesn't appear to have been used. Equipment appears to be a better choice.

Note:

JG: Almost certainly safe to just drop the table and remove this file.

Appears to have been intended to generate barcode for arbitrary instruments, beginning LE. Can't see any entries in the production database, so assume this went unused. The Equipment table does have entries, and seems to perform an almost identical function

Constant Summary collapse

@@barcode_prefix =
'LE'

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

Instance Method Details

#barcode_prefixObject


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

def barcode_prefix
  @@barcode_prefix
end

#generate_barcodeObject

Raises:

  • (Exception.new)

12
13
14
15
16
17
# File 'app/models/implement.rb', line 12

def generate_barcode
  raise Exception.new, "Can't generate barcode with a null ID" if id == 0

  b = Barcode.calculate_barcode(barcode_prefix, id)
  Barcode.barcode_to_human b
end

#human_barcodeObject


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

def human_barcode
  Barcode.barcode_to_human barcode
end

#save_and_generate_barcodeObject


27
28
29
30
31
32
# File 'app/models/implement.rb', line 27

def save_and_generate_barcode
  ActiveRecord::Base.transaction do
    save and self.barcode = generate_barcode
    save
  end
end