Class: SampleManifestAsset

Inherits:
ApplicationRecord show all
Defined in:
app/models/sample_manifest_asset.rb

Overview

Keeps track of sanger_sample_ids which have been allocated to a SampleManifest and associates them with the corresponding Receptacle

Instance Method Summary collapse

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

Instance Method Details

#aliquotObject



25
26
27
# File 'app/models/sample_manifest_asset.rb', line 25

def aliquot
  asset.aliquots.detect { |a| a.sample_id == sample.id }
end

#aliquotsObject



30
31
32
33
34
35
# File 'app/models/sample_manifest_asset.rb', line 30

def aliquots
  # JG: I'm afraid I'm not entirely sure why we're expecting aliquots of multiple samples in here
  # as multiplexed libraries still link to the 'library tube'. However I've decided to preserve
  # the behaviour of the original :aliquot implementation.
  asset.aliquots.select { |a| a.sample_id == sample.id }
end

#find_or_create_sampleObject

Returns the existing sample, or generates a new one if it doesn’t exist



21
22
23
# File 'app/models/sample_manifest_asset.rb', line 21

def find_or_create_sample
  self.sample ||= create_sample
end