Class: LibPoolNormTubeGenerator
- Inherits:
-
Object
- Object
- LibPoolNormTubeGenerator
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/lib_pool_norm_tube_generator.rb
Instance Attribute Summary collapse
-
#asset_group ⇒ Object
readonly
Returns the value of attribute asset_group.
-
#plate ⇒ Object
Returns the value of attribute plate.
-
#study ⇒ Object
readonly
Returns the value of attribute study.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#create! ⇒ Object
rubocop:todo Metrics/MethodLength.
- #destination_tubes ⇒ Object
-
#initialize(barcode, user, study) ⇒ LibPoolNormTubeGenerator
constructor
A new instance of LibPoolNormTubeGenerator.
- #lib_pool_tubes ⇒ Object
- #set_plate(barcode) ⇒ Object
- #transfer_template ⇒ Object
Constructor Details
#initialize(barcode, user, study) ⇒ LibPoolNormTubeGenerator
Returns a new instance of LibPoolNormTubeGenerator.
13 14 15 16 17 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 13 def initialize(, user, study) self.plate = @user = user @study = study end |
Instance Attribute Details
#asset_group ⇒ Object (readonly)
Returns the value of attribute asset_group.
6 7 8 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 6 def asset_group @asset_group end |
#plate ⇒ Object
Returns the value of attribute plate.
5 6 7 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 5 def plate @plate end |
#study ⇒ Object (readonly)
Returns the value of attribute study.
6 7 8 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 6 def study @study end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 6 def user @user end |
Instance Method Details
#create! ⇒ Object
rubocop:todo Metrics/MethodLength
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 44 def create! # rubocop:todo Metrics/AbcSize if valid? begin ActiveRecord::Base.transaction do lib_pool_tubes.each do |tube| pass_and_complete(tube) pass_and_complete(create_lib_pool_norm_tube(tube)) end @asset_group = AssetGroup.create!( assets: destination_tubes.map(&:receptacle), study: study, name: "#{plate.}_qc_completed_tubes" ) end true rescue => e Rails.logger.error("Pool generation error: #{e.}") Rails.logger.error(e.backtrace) false end end end |
#destination_tubes ⇒ Object
39 40 41 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 39 def destination_tubes @destination_tubes ||= [] end |
#lib_pool_tubes ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 31 def lib_pool_tubes @lib_pool_tubes ||= plate .children .select { |c| c.is_a?(StockMultiplexedLibraryTube) } .reject { |tube| tube.state == 'failed' || tube.state == 'qc_complete' || tube.state == 'cancelled' } end |
#set_plate(barcode) ⇒ Object
27 28 29 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 27 def set_plate() Plate.().includes(wells: { requests: %i[request_type target_asset] }).first end |
#transfer_template ⇒ Object
19 20 21 |
# File 'app/models/lib_pool_norm_tube_generator.rb', line 19 def transfer_template @transfer_template ||= TransferTemplate.find_by!(transfer_class_name: 'Transfer::BetweenTubesBySubmission') end |