Module: Aliquotable

Extended by:
ActiveSupport::Concern
Included in:
Pacbio::Library, Pacbio::Pool, Pacbio::Request, Pacbio::Well
Defined in:
app/models/concerns/aliquotable.rb

Overview

Aliquotable

This module provides functionality for models that can have aliquots. An aliquot is a portion or sample of a larger entity. Models that include this module will have associations and methods related to aliquots.

Instance Method Summary collapse

Instance Method Details

#used_aliquots_volume โ‡’ Object

Method: used_aliquots_volume

This method is used to validate the volume of used aliquots in a well. It is typically used as a validation method before updating a pool record. Returns false if the volume of any used aliquot is insufficient.

[View source]

92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'app/models/concerns/aliquotable.rb', line 92

def used_aliquots_volume
  # Get all the aliquots that are libraries or pools and have insufficient volume
  failed_aliquots = used_aliquots.select do |aliquot|
    ['Pacbio::Library', 'Pacbio::Pool'].include?(aliquot.source_type) &&
      !aliquot.source.available_volume_sufficient
  end
  return if failed_aliquots.empty?

  # If there are failed aliquots we want to collect the source barcodes add an error to the pool
  failed_barcodes = failed_aliquots.map { |aliquot| aliquot.source.tube.barcode }.join(',')
  errors.add(:base, "Insufficient volume available for #{failed_barcodes}")
  false
end