Class: Transfer

Inherits:
ApplicationRecord show all
Includes:
Uuid::Uuidable
Defined in:
app/models/transfer.rb

Overview

Note:

TransferRequestCollection is preferred, as it allows the client applications to control the transfer behaviour.

A transfer handles the transfer of material from one piece of labware to another. Different classes are used to determine exactly how the transfers are performed.

Defined Under Namespace

Modules: Associations, ControlledDestinations, State, TransfersBySchema, TransfersToKnownDestination Classes: BetweenPlateAndTubes, BetweenPlates, BetweenPlatesBySubmission, BetweenSpecificTubes, BetweenTubesBySubmission, FromPlateToSpecificTubes, FromPlateToSpecificTubesByPool, FromPlateToTube, FromPlateToTubeByMultiplex, FromPlateToTubeBySubmission

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Class Method Details

.preview!(attributes) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/models/transfer.rb', line 28

def self.preview!(attributes)
  new(attributes) do |transfer|
    raise ActiveRecord::RecordInvalid, transfer unless transfer.valid?

    transfer.unsaved_uuid!
    transfer.send(:each_transfer) do |source, destination|
      # Needs to do nothing at all as the transfers will be recorded
    end
  end
end

Instance Method Details

#validate_transfers(positions, plate, plate_type) ⇒ Object

Given a list of well map_descriptions (eg. A1) validates that all are present on the plate, otherwise generates a validation error. Also valid if the plate is not specified. Used by: BetweenPlates and FromPlateToTube

Parameters:

  • positions (Array)

    Array of map_descriptions to test



46
47
48
49
50
51
# File 'app/models/transfer.rb', line 46

def validate_transfers(positions, plate, plate_type)
  invalid_positions = plate&.invalid_positions(positions)
  return true if invalid_positions.blank? # We either have no plate, or all positions are valid

  errors.add(:transfers, "#{invalid_positions.join(', ')} are not valid positions for the #{plate_type} plate")
end