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

Methods included from Warren::BroadcastMessages

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

Instance Method Details

#barcode_prefixObject


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

def barcode_prefix
  @@barcode_prefix
end

#generate_barcodeObject

Raises:

  • (Exception.new)

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

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


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

def human_barcode
  Barcode.barcode_to_human barcode
end

#save_and_generate_barcodeObject


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

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