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
59 60 61 |
# File 'app/models/pooling.rb', line 59 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
51 52 53 |
# File 'app/models/pooling.rb', line 51 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 48 49 |
# File 'app/models/pooling.rb', line 42 def each_transfer source_assets.each do |source_asset| yield source_asset, @stock_mx_tube || @standard_mx_tube end 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
77 78 79 |
# File 'app/models/pooling.rb', line 77 def @message ||= Hash.new('') end |
#print_job ⇒ Object
71 72 73 74 75 |
# File 'app/models/pooling.rb', line 71 def print_job @print_job ||= LabelPrinter::PrintJob.new(, LabelPrinter::Label::MultiplexedTube, assets: target_assets, count: count) end |
#print_job_required? ⇒ Boolean
67 68 69 |
# File 'app/models/pooling.rb', line 67 def print_job_required? .present? && count.to_i.positive? end |
#stock_mx_tube_required? ⇒ Boolean
63 64 65 |
# File 'app/models/pooling.rb', line 63 def stock_mx_tube_required? stock_mx_tube_required.present? end |
#tag_clash_report ⇒ Object
81 82 83 |
# File 'app/models/pooling.rb', line 81 def tag_clash_report @tag_clash_report ||= Pooling::TagClashReport.new(self) end |
#target_assets ⇒ Object
55 56 57 |
# File 'app/models/pooling.rb', line 55 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 |