Class: Heron::Factories::TubeRack
- Inherits:
- 
      Object
      
        - Object
- Heron::Factories::TubeRack
 
- Includes:
- ActiveModel::Model, Concerns::Contents, Concerns::CoordinatesSupport, Concerns::ForeignBarcodes, Concerns::Recipients, Concerns::RecipientsCoordinates
- Defined in:
- app/models/heron/factories/tube_rack.rb
Overview
Factory class to create Heron tube racks
Constant Summary
Constants included from Concerns::CoordinatesSupport
Concerns::CoordinatesSupport::LOCATION_REGEXP
Instance Attribute Summary collapse
- 
  
    
      #sample_tubes  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute sample_tubes. 
- 
  
    
      #tube_rack  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute tube_rack. 
Instance Method Summary collapse
- #barcode ⇒ Object
- #content_factory ⇒ Object
- 
  
    
      #initialize(params)  ⇒ TubeRack 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of TubeRack. 
- #purpose ⇒ Object
- #purpose_uuid ⇒ Object
- #recipient_factory ⇒ Object
- #recipients_key ⇒ Object
- #sample_study_names ⇒ Object
- #save ⇒ Object
Methods included from Concerns::Contents
#_factories_for_location, #add_aliquots_into_location, #add_aliquots_into_locations, #contents, included, #label_for_error_message, #params_for_contents, #study_uuid
Methods included from Concerns::Recipients
#check_recipients, included, #params_for_recipient, #recipients
Methods included from Concerns::RecipientsCoordinates
#check_recipient_coordinates, included
Methods included from Concerns::ForeignBarcodes
#barcode_format, #check_barcode_format, #check_foreign_barcode_unique, included
Methods included from Concerns::CoordinatesSupport
#coordinate_valid?, #unpad_coordinate
Constructor Details
#initialize(params) ⇒ TubeRack
Returns a new instance of TubeRack.
| 19 20 21 | # File 'app/models/heron/factories/tube_rack.rb', line 19 def initialize(params) @params = params end | 
Instance Attribute Details
#sample_tubes ⇒ Object
Returns the value of attribute sample_tubes.
| 15 16 17 | # File 'app/models/heron/factories/tube_rack.rb', line 15 def sample_tubes @sample_tubes end | 
#tube_rack ⇒ Object
Returns the value of attribute tube_rack.
| 15 16 17 | # File 'app/models/heron/factories/tube_rack.rb', line 15 def tube_rack @tube_rack end | 
Instance Method Details
#barcode ⇒ Object
| 35 36 37 | # File 'app/models/heron/factories/tube_rack.rb', line 35 def @params[:barcode] end | 
#content_factory ⇒ Object
| 31 32 33 | # File 'app/models/heron/factories/tube_rack.rb', line 31 def content_factory ::Heron::Factories::Sample end | 
#purpose ⇒ Object
| 45 46 47 | # File 'app/models/heron/factories/tube_rack.rb', line 45 def purpose @purpose ||= ::TubeRack::Purpose.with_uuid(purpose_uuid).first end | 
#purpose_uuid ⇒ Object
| 41 42 43 | # File 'app/models/heron/factories/tube_rack.rb', line 41 def purpose_uuid @params[:purpose_uuid] end | 
#recipient_factory ⇒ Object
| 27 28 29 | # File 'app/models/heron/factories/tube_rack.rb', line 27 def recipient_factory ::Heron::Factories::Tube end | 
#recipients_key ⇒ Object
| 23 24 25 | # File 'app/models/heron/factories/tube_rack.rb', line 23 def recipients_key :tubes end | 
#sample_study_names ⇒ Object
| 65 66 67 68 69 70 71 72 73 74 75 76 | # File 'app/models/heron/factories/tube_rack.rb', line 65 def sample_study_names return unless @tube_rack @tube_rack .tubes .each_with_object([]) do |tube, study_names| next if tube.aliquots.first.blank? study_names << tube.aliquots.first.study.name if tube.aliquots.first.study.present? end .uniq end | 
#save ⇒ Object
| 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # File 'app/models/heron/factories/tube_rack.rb', line 49 def save return false unless valid? ActiveRecord::Base.transaction do @tube_rack = ::TubeRack.create!(size:, purpose:) Barcode.create!(labware: tube_rack, barcode: , format: ) create_recipients! create_contents! ::TubeRackStatus.create!(barcode: , status: :created, labware: @tube_rack) end true end |