Module: ModelExtensions::Plate

Included in:
Plate
Defined in:
app/api/model_extensions/plate.rb

Overview

Included in Plate The intent of this file was to provide methods specific to the V1 API

Defined Under Namespace

Modules: NamedScopeHelpers

Constant Summary collapse

PLATE_INCLUDES =
:plate_metadata, { wells: %i[map transfer_requests_as_target uuid_object] }].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



14
15
16
17
18
19
20
# File 'app/api/model_extensions/plate.rb', line 14

def self.included(base)
  base.class_eval do
    scope :include_plate_purpose, -> { includes(:plate_purpose) }
    scope :include_plate_metadata, -> { includes(:plate_metadata) }
    delegate :pool_id_for_well, to: :plate_purpose, allow_nil: true
  end
end

Instance Method Details

#library_source_plateObject



22
23
24
# File 'app/api/model_extensions/plate.rb', line 22

def library_source_plate
  plate_purpose.library_source_plate(self)
end

#library_source_platesObject



26
27
28
# File 'app/api/model_extensions/plate.rb', line 26

def library_source_plates
  plate_purpose.library_source_plate(self)
end

#pre_cap_groupsObject

Adds pre-capture pooling information, we need to delegate this to the stock plate, as we need all the wells Currently used in Transfer::BetweenPlates to set submission id, we should switch to doing this directly via Limber with transfer request collections



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/api/model_extensions/plate.rb', line 33

def pre_cap_groups # rubocop:todo Metrics/AbcSize
  Request
    .
    .for_pre_cap_grouping_of(self)
    .each_with_object({}) do |request, groups|
      groups[request.group_id] = { wells: request.group_into.split(',') }.tap do |pool_information|
        pool_information[:pre_capture_plex_level] ||= request..pre_capture_plex_level

        # We supply the submission id to assist with correctly tagging transfer requests later
        pool_information[:submission_id] ||= request.submission_id
      end unless request.group_id.nil?
    end
end