Class: Pooling
- Inherits:
-
Object
- Object
- Pooling
- 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
-
#barcode_printer ⇒ Object
Returns the value of attribute barcode_printer.
- #barcodes ⇒ Object
-
#count ⇒ Object
Returns the value of attribute count.
- #source_assets ⇒ Object
-
#standard_mx_tube ⇒ Object
Returns the value of attribute standard_mx_tube.
-
#stock_mx_tube ⇒ Object
Returns the value of attribute stock_mx_tube.
-
#stock_mx_tube_required ⇒ Object
Returns the value of attribute stock_mx_tube_required.
Instance Method Summary collapse
- #each_transfer {|@stock_mx_tube, @standard_mx_tube| ... } ⇒ Object
- #execute ⇒ Object
- #message ⇒ Object
- #print_job ⇒ Object
- #print_job_required? ⇒ Boolean
- #stock_mx_tube_required? ⇒ Boolean
- #tag_clash_report ⇒ Object
- #target_assets ⇒ Object
- #transfer ⇒ Object
Instance Attribute Details
#barcode_printer ⇒ Object
Returns the value of attribute barcode_printer.
9 10 11 |
# File 'app/models/pooling.rb', line 9 def @barcode_printer end |
#barcodes ⇒ Object
57 58 59 |
# File 'app/models/pooling.rb', line 57 def @barcodes || [] end |
#count ⇒ Object
Returns the value of attribute count.
9 10 11 |
# File 'app/models/pooling.rb', line 9 def count @count end |
#source_assets ⇒ Object
49 50 51 |
# File 'app/models/pooling.rb', line 49 def source_assets @source_assets ||= find_source_assets end |
#standard_mx_tube ⇒ Object
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_tube ⇒ Object
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_required ⇒ Object
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
#each_transfer {|@stock_mx_tube, @standard_mx_tube| ... } ⇒ Object
42 43 44 45 46 47 |
# File 'app/models/pooling.rb', line 42 def each_transfer source_assets.each { |source_asset| yield source_asset, @stock_mx_tube || @standard_mx_tube } return unless stock_mx_tube_required? yield @stock_mx_tube, @standard_mx_tube end |
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/pooling.rb', line 16 def execute return false unless valid? if stock_mx_tube_required? @stock_mx_tube = Tube::Purpose.stock_mx_tube.create!(name: '(s)') @stock_mx_tube.parents = source_assets end @standard_mx_tube = Tube::Purpose.standard_mx_tube.create! @standard_mx_tube.parents = @stock_mx_tube ? [@stock_mx_tube] : source_assets transfer execute_print_job true end |
#message ⇒ Object
79 80 81 |
# File 'app/models/pooling.rb', line 79 def @message ||= Hash.new('') end |
#print_job ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/models/pooling.rb', line 69 def print_job @print_job ||= LabelPrinter::PrintJob.new( , LabelPrinter::Label::MultiplexedTube, assets: target_assets, count: count ) end |
#print_job_required? ⇒ Boolean
65 66 67 |
# File 'app/models/pooling.rb', line 65 def print_job_required? .present? && count.to_i.positive? end |
#stock_mx_tube_required? ⇒ Boolean
61 62 63 |
# File 'app/models/pooling.rb', line 61 def stock_mx_tube_required? stock_mx_tube_required.present? end |
#tag_clash_report ⇒ Object
83 84 85 |
# File 'app/models/pooling.rb', line 83 def tag_clash_report @tag_clash_report ||= Pooling::TagClashReport.new(self) end |
#target_assets ⇒ Object
53 54 55 |
# File 'app/models/pooling.rb', line 53 def target_assets @target_assets ||= [stock_mx_tube, standard_mx_tube].compact end |
#transfer ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/pooling.rb', line 31 def transfer each_transfer do |source_asset, target_asset| # These transfers are not being performed to fulfil a specific request, so we explicitly # pass in a Request Null object. This will disable the attempt to detect an outer request. # We don't use nil as its *far* to easy to end up with nil by accident, so basing key behaviour # off it is risky. TransferRequest.create!(asset: source_asset, target_asset: target_asset, outer_request: Request::None.new) end [:notice] = [:notice] + success end |