Class: Pooling

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/pooling.rb

Overview

Used by PoolingsController to take multiple scanned Tube barcodes containing one or more aliquots and use them to generate a new MultiplexedLibraryTube

Defined Under Namespace

Classes: TagClashReport

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#barcode_printerObject

Returns the value of attribute barcode_printer


9
10
11
# File 'app/models/pooling.rb', line 9

def barcode_printer
  @barcode_printer
end

#barcodesObject


43
44
45
# File 'app/models/pooling.rb', line 43

def barcodes
  @barcodes || []
end

#countObject

Returns the value of attribute count


9
10
11
# File 'app/models/pooling.rb', line 9

def count
  @count
end

#source_assetsObject


35
36
37
# File 'app/models/pooling.rb', line 35

def source_assets
  @source_assets ||= find_source_assets
end

#standard_mx_tubeObject

Returns the value of attribute standard_mx_tube


9
10
11
# File 'app/models/pooling.rb', line 9

def standard_mx_tube
  @standard_mx_tube
end

#stock_mx_tubeObject

Returns the value of attribute stock_mx_tube


9
10
11
# File 'app/models/pooling.rb', line 9

def stock_mx_tube
  @stock_mx_tube
end

#stock_mx_tube_requiredObject

Returns the value of attribute stock_mx_tube_required


9
10
11
# File 'app/models/pooling.rb', line 9

def stock_mx_tube_required
  @stock_mx_tube_required
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
# File 'app/models/pooling.rb', line 16

def execute
  return false unless valid?

  @stock_mx_tube = Tube::Purpose.stock_mx_tube.create!(name: '(s)') if stock_mx_tube_required?
  @standard_mx_tube = Tube::Purpose.standard_mx_tube.create!
  transfer
  execute_print_job
  true
end

#messageObject


61
62
63
# File 'app/models/pooling.rb', line 61

def message
  @message ||= {}
end

55
56
57
58
59
# File 'app/models/pooling.rb', line 55

def print_job
  @print_job ||= LabelPrinter::PrintJob.new(barcode_printer,
                                            LabelPrinter::Label::MultiplexedTube,
                                            assets: target_assets, count: count)
end

Returns:

  • (Boolean)

51
52
53
# File 'app/models/pooling.rb', line 51

def print_job_required?
  barcode_printer.present?
end

#stock_mx_tube_required?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'app/models/pooling.rb', line 47

def stock_mx_tube_required?
  stock_mx_tube_required.present?
end

#tag_clash_reportObject


65
66
67
# File 'app/models/pooling.rb', line 65

def tag_clash_report
  @tag_clash_report ||= Pooling::TagClashReport.new(self)
end

#target_assetsObject


39
40
41
# File 'app/models/pooling.rb', line 39

def target_assets
  @target_assets ||= [stock_mx_tube, standard_mx_tube].compact
end

#transferObject


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

def transfer
  target_assets.each do |target_asset|
    source_assets.each do |source_asset|
      TransferRequest.create!(asset: source_asset, target_asset: target_asset)
    end
  end
  message[:notice] = (message[:notice] || '') + success
end