Class: LabwareCreators::FinalTube

Inherits:
Base
  • Object
show all
Includes:
SupportParent::TubeOnly
Defined in:
app/models/labware_creators/final_tube.rb

Overview

The final tubes form handles the transfer to the Multiplexed Library Tube that gets generated upfront when the submission is made. It has two behaviours: 1) For single plate pools it generates the new tube immediately 2) For cross-plate pools (such as dual index) it prompts the user to scan

all tubes in the submission

This check is based on the contents of sibling_tubes in the json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from LabwareCreators::Base

Instance Attribute Details

#all_tube_transfersObject (readonly)

Returns the value of attribute all_tube_transfers.



17
18
19
# File 'app/models/labware_creators/final_tube.rb', line 17

def all_tube_transfers
  @all_tube_transfers
end

Instance Method Details

#all_ready?Boolean

Returns:

  • (Boolean)


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

def all_ready?
  siblings.all?(&:ready?)
end

#create_labware!Object



30
31
32
33
34
# File 'app/models/labware_creators/final_tube.rb', line 30

def create_labware!
  @all_tube_transfers =
    parents.map { |this_parent_uuid| transfer_template.create!(user: user_uuid, source: this_parent_uuid) }
  true
end

#custom_input_expectedObject



36
37
38
# File 'app/models/labware_creators/final_tube.rb', line 36

def custom_input_expected
  errors.add(:parent, 'has sibling tubes, which must be pooled.') unless barcodes_provided?
end

#each_sibling(&block) ⇒ Object



22
23
24
# File 'app/models/labware_creators/final_tube.rb', line 22

def each_sibling(&block)
  siblings.each(&block)
end

#parentObject Also known as: tube



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

def parent
  @parent ||= api.tube.find(parent_uuid)
end

#parentsObject



66
67
68
# File 'app/models/labware_creators/final_tube.rb', line 66

def parents
  @parents || [parent_uuid]
end

#parents=(barcode_hash) ⇒ Object



54
55
56
57
58
59
# File 'app/models/labware_creators/final_tube.rb', line 54

def parents=(barcode_hash)
  return unless barcode_hash.respond_to?(:keys)

  @barcodes = barcode_hash.select { |_barcode, selected| selected == '1' }.keys
  @parents = @barcodes.map { |barcode| barcode_to_uuid(barcode) }
end

#redirection_targetObject

We pretend that we’ve added a new blank tube when we’re actually transferring to the tube on the original LibraryRequest

Raises:

  • (StandardError)


42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/labware_creators/final_tube.rb', line 42

def redirection_target
  return :contents_not_transfered_to_mx_tube if all_tube_transfers.nil?

  destination_uuids = all_tube_transfers.map { |tt| tt.destination.uuid }.uniq

  # The client_api returns a 'barcoded asset' here, rather than a tube.
  # We know that its a tube though, so wrap it in this useful tool
  return TubeProxy.new(destination_uuids.first) if destination_uuids.one?

  raise StandardError, 'Multiple targets found. You may have scanned tubes from separate submissions.'
end