Class: SampleManifest::SampleTubeBehaviour::Core

Inherits:
SampleManifest::SharedTubeBehaviour::Base show all
Includes:
CoreBehaviour::NoSpecializedValidation, CoreBehaviour::StockAssets
Defined in:
app/models/sample_manifest/sample_tube_behaviour.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CoreBehaviour::StockAssets

#generate_sample_and_aliquot

Methods included from CoreBehaviour::NoSpecializedValidation

#specialized_fields, #validate_specialized_fields

Methods inherited from SampleManifest::SharedTubeBehaviour::Base

#details_array, #updated_by!

Methods included from CoreBehaviour::Shared

#details, #generate_sanger_ids, included

Constructor Details

#initialize(manifest) ⇒ Core

Returns a new instance of Core


8
9
10
11
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 8

def initialize(manifest)
  @manifest = manifest
  @tubes = []
end

Instance Attribute Details

#tubesObject (readonly)

Returns the value of attribute tubes


6
7
8
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 6

def tubes
  @tubes
end

Instance Method Details

#acceptable_purposesObject


28
29
30
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 28

def acceptable_purposes
  Tube::Purpose.where(target_type: SampleTube)
end

#default_purposeObject


32
33
34
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 32

def default_purpose
  Tube::Purpose.standard_sample_tube
end

#generateObject


13
14
15
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 13

def generate
  @tubes = generate_tubes(purpose)
end

#included_resourcesObject


49
50
51
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 49

def included_resources
  [{ sample: :sample_metadata, asset: %i[aliquots barcodes] }]
end

#io_samplesObject


17
18
19
20
21
22
23
24
25
26
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 17

def io_samples
  samples.map do |sample|
    {
      sample: sample,
      container: {
        barcode: sample.primary_receptacle.human_barcode
      }
    }
  end
end

#labwareObject Also known as: printables


44
45
46
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 44

def labware
  tubes | labware_from_samples | @manifest.assets.map(&:labware)
end

#labware=(labware) ⇒ Object


40
41
42
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 40

def labware=(labware)
  @tubes = labware
end

#labware_from_samplesObject


36
37
38
# File 'app/models/sample_manifest/sample_tube_behaviour.rb', line 36

def labware_from_samples
  samples.map { |s| s.primary_receptacle.labware }
end