Class: Purpose

Inherits:
ApplicationRecord show all
Includes:
Relationship::Associations, Uuid::Uuidable
Defined in:
app/models/purpose.rb

Direct Known Subclasses

PlatePurpose, Tube::Purpose

Defined Under Namespace

Classes: Relationship

Instance Method Summary collapse

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from Relationship::Associations

included

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_typeObject


30
31
32
# File 'app/models/purpose.rb', line 30

def barcode_type
  barcode_printer_type&.printer_type_id
end

#prefix=(prefix) ⇒ Object


38
39
40
# File 'app/models/purpose.rb', line 38

def prefix=(prefix)
  self.barcode_prefix = BarcodePrefix.find_or_create_by(prefix: prefix)
end

#set_default_barcode_prefixObject


42
43
44
# File 'app/models/purpose.rb', line 42

def set_default_barcode_prefix
  self.prefix ||= default_prefix
end

#source_plate(asset) ⇒ Object


26
27
28
# File 'app/models/purpose.rb', line 26

def source_plate(asset)
  source_purpose_id.present? ? asset.ancestor_of_purpose(source_purpose_id) : asset.stock_plate
end

#target_classObject


34
35
36
# File 'app/models/purpose.rb', line 34

def target_class
  target_type.constantize
end