Class: Heron::Factories::PlateFromRack

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/heron/factories/plate_from_rack.rb

Overview

Factory class to create Heron tube racks

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#plateObject

Returns the value of attribute plate.



9
10
11
# File 'app/models/heron/factories/plate_from_rack.rb', line 9

def plate
  @plate
end

#plate_purposeObject

Returns the value of attribute plate_purpose.



9
10
11
# File 'app/models/heron/factories/plate_from_rack.rb', line 9

def plate_purpose
  @plate_purpose
end

#tube_rackObject

Returns the value of attribute tube_rack.



9
10
11
# File 'app/models/heron/factories/plate_from_rack.rb', line 9

def tube_rack
  @tube_rack
end

Instance Method Details

#plate_contentsObject



26
27
28
29
30
31
32
33
# File 'app/models/heron/factories/plate_from_rack.rb', line 26

def plate_contents
  tube_rack.racked_tubes.map do |racked_tube|
    {}.tap do |obj|
      obj['location'] = racked_tube.coordinate
      obj['sample_tube_uuid'] = racked_tube.tube.uuid
    end
  end
end

#saveObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/heron/factories/plate_from_rack.rb', line 14

def save
  return false unless valid?

  ActiveRecord::Base.transaction do
    @plate = plate_purpose.create!
    ExtractionAttribute.create!(attributes_update: plate_contents, target: @plate, created_by: 'heron')

    AssetLink.create_edge(tube_rack, plate)
  end
  true
end