Class: Heron::Factories::Plate
- Inherits:
-
Object
- Object
- Heron::Factories::Plate
- Includes:
- ActiveModel::Model, Concerns::Contents, Concerns::CoordinatesSupport, Concerns::Eventful, Concerns::ForeignBarcodes, Concerns::RecipientsCoordinates
- Defined in:
- app/models/heron/factories/plate.rb
Overview
Factory class to create Heron tube racks
Constant Summary
Constants included from Concerns::CoordinatesSupport
Concerns::CoordinatesSupport::LOCATION_REGEXP
Instance Attribute Summary collapse
-
#plate ⇒ Object
Returns the value of attribute plate.
-
#purpose ⇒ Object
Returns the value of attribute purpose.
Instance Method Summary collapse
- #barcode ⇒ Object
- #content_factory ⇒ Object
-
#initialize(params) ⇒ Plate
constructor
A new instance of Plate.
- #recipients_key ⇒ Object
- #sample_study_names ⇒ Object
-
#save ⇒ Object
rubocop:todo Metrics/MethodLength.
Methods included from Concerns::Eventful
#add_all_errors_from_event, #add_all_errors_from_events, #build_events, #params_for_event, #rollback_for_events
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::RecipientsCoordinates
#check_recipient_coordinates, included
Methods included from Concerns::CoordinatesSupport
#coordinate_valid?, #unpad_coordinate
Methods included from Concerns::ForeignBarcodes
#barcode_format, #check_barcode_format, #check_foreign_barcode_unique, included
Constructor Details
#initialize(params) ⇒ Plate
Returns a new instance of Plate.
18 19 20 |
# File 'app/models/heron/factories/plate.rb', line 18 def initialize(params) @params = params end |
Instance Attribute Details
#plate ⇒ Object
Returns the value of attribute plate.
14 15 16 |
# File 'app/models/heron/factories/plate.rb', line 14 def plate @plate end |
#purpose ⇒ Object
Returns the value of attribute purpose.
14 15 16 |
# File 'app/models/heron/factories/plate.rb', line 14 def purpose @purpose end |
Instance Method Details
#barcode ⇒ Object
30 31 32 |
# File 'app/models/heron/factories/plate.rb', line 30 def @params[:barcode] end |
#content_factory ⇒ Object
26 27 28 |
# File 'app/models/heron/factories/plate.rb', line 26 def content_factory ::Heron::Factories::Sample end |
#recipients_key ⇒ Object
22 23 24 |
# File 'app/models/heron/factories/plate.rb', line 22 def recipients_key :wells end |
#sample_study_names ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/heron/factories/plate.rb', line 56 def sample_study_names return unless @plate @plate .wells .each_with_object([]) do |well, study_names| next if well.aliquots.first.blank? study_names << well.aliquots.first.study.name if well.aliquots.first.study.present? end .uniq end |
#save ⇒ Object
rubocop:todo Metrics/MethodLength
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/heron/factories/plate.rb', line 34 def save # rubocop:todo Metrics/MethodLength return false unless valid? @output_result = true ActiveRecord::Base.transaction do @plate = purpose.create! Barcode.create!(labware: @plate, barcode: , format: ) create_contents! if @params[:events] events = build_events(@plate) events.each do |event| rollback_for_events(events) unless event.valid? event.save end end end @output_result end |