Class: SampleManifest::TubeRackBehaviour::Core

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

Overview

Specifies behaviour for generation of Tube Rack Manifests Ends up being included in SampleManifest model because is instantiated in CoreBehaviour

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CoreBehaviour::StockAssets

#generate_sample_and_aliquot, #stocks?

Methods included from CoreBehaviour::NoSpecializedValidation

#specialized_fields, #validate_specialized_fields

Methods inherited from 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.


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

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

Instance Attribute Details

#tubesObject (readonly)

Returns the value of attribute tubes.


10
11
12
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 10

def tubes
  @tubes
end

Instance Method Details

#acceptable_purposesObject


22
23
24
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 22

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

#acceptable_rack_purposesObject


26
27
28
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 26

def acceptable_rack_purposes
  TubeRack::Purpose.where(target_type: TubeRack)
end

#default_purposeObject


30
31
32
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 30

def default_purpose
  Tube::Purpose.standard_sample_tube
end

#default_tube_rack_purposeObject


34
35
36
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 34

def default_tube_rack_purpose
  TubeRack::Purpose.standard_tube_rack
end

#generateObject


17
18
19
20
# File 'app/models/sample_manifest/tube_rack_behaviour.rb', line 17

def generate
  desired_number_of_tubes = count * @manifest.tube_rack_purpose.size
  @tubes = generate_tubes(purpose, desired_number_of_tubes)
end

#included_resourcesObject

when uploading the manifest, this specifies which resources are queried and stored in the Cache accessed through sample_manifest.sample_manifest_assets.includes(<resources below>)


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

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