Class: Tube::Purpose

Inherits:
Purpose show all
Defined in:
app/models/tube/purpose.rb

Overview

Base class for the all tube purposes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Purpose

#barcode_type, #prefix=, #set_default_barcode_prefix, #source_plate, #target_class

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from Purpose::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

Class Method Details

.standard_library_tubeObject


51
52
53
54
55
# File 'app/models/tube/purpose.rb', line 51

def standard_library_tube
  Tube::Purpose.create_with(
    target_type: 'LibraryTube'
  ).find_or_create_by!(name: 'Standard library')
end

.standard_mx_tubeObject


57
58
59
60
61
# File 'app/models/tube/purpose.rb', line 57

def standard_mx_tube
  Tube::StandardMx.create_with(
    target_type: 'MultiplexedLibraryTube'
  ).find_or_create_by!(name: 'Standard MX')
end

.standard_sample_tubeObject


45
46
47
48
49
# File 'app/models/tube/purpose.rb', line 45

def standard_sample_tube
  Tube::Purpose.create_with(
    target_type: 'SampleTube'
  ).find_or_create_by!(name: 'Standard sample')
end

.stock_library_tubeObject


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

def stock_library_tube
  Tube::Purpose.create_with(
    target_type: 'StockLibraryTube'
  ).find_or_create_by!(name: 'Stock library')
end

.stock_mx_tubeObject


39
40
41
42
43
# File 'app/models/tube/purpose.rb', line 39

def stock_mx_tube
  Tube::StockMx.create_with(
    target_type: 'StockMultiplexedLibraryTube'
  ).find_or_create_by!(name: 'Stock MX')
end

Instance Method Details

#create!(*args, &block) ⇒ Object


20
21
22
23
24
25
# File 'app/models/tube/purpose.rb', line 20

def create!(*args, &block)
  options = args.extract_options!
  options[:purpose] = self
  options[:barcode_prefix] ||= barcode_prefix
  target_class.create_with_barcode!(*args, options, &block).tap { |t| tubes << t }
end

#library_source_plates(_) ⇒ Object


16
17
18
# File 'app/models/tube/purpose.rb', line 16

def library_source_plates(_)
  []
end

#sibling_tubes(_tube) ⇒ Object


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

def sibling_tubes(_tube)
  nil
end

#stock_plate(_) ⇒ Object

Tubes of the general types have no stock plate!


12
13
14
# File 'app/models/tube/purpose.rb', line 12

def stock_plate(_)
  nil
end