Class: PlatePurpose::AdditionalInput

Inherits:
PlatePurpose show all
Defined in:
app/models/plate_purpose/additional_input.rb

Overview

Class to support a different state machine for inputs added in the middle of a workflow

Constant Summary collapse

READY_STATE =
'passed'

Instance Method Summary collapse

Methods inherited from PlatePurpose

#asset_shape, #attached?, #cherrypick_completed, #cherrypick_in_rows?, #child_plate_purposes, #create!, #input_plate=, #plate_height, #plate_width, #pool_wells, #size, #source_wells_for, stock_plate_purpose

Methods included from Api::PlatePurposeIo::Extensions

included, #json_root

Methods included from Purpose::Relationship::Associations

included

Methods inherited from Purpose

#barcode_type, #prefix=, #set_default_barcode_prefix, #source_plate, #source_plates, #source_purpose_name=, #target_class

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods included from SharedBehaviour::Named

included

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#library_creation?(plate) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'app/models/plate_purpose/additional_input.rb', line 16

def library_creation?(plate)
  return false if plate.wells.with_contents.empty?
  plate.wells.with_contents.all? do |well|
    return false if well.requests.empty?
    well
      .requests
      .filter { |a| !a.is_a?(CreateAssetRequest) }
      .all? { |request| request.is_a?(Request::LibraryCreation) || request.is_a?(LibraryCreationRequest) }
  end
end

#state_of(plate) ⇒ Object



7
8
9
10
# File 'app/models/plate_purpose/additional_input.rb', line 7

def state_of(plate)
  return READY_STATE if valid_intermediate_input?(plate)
  super(plate)
end

#valid_intermediate_input?(plate) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/models/plate_purpose/additional_input.rb', line 12

def valid_intermediate_input?(plate)
  [plate.ancestors.count.zero?, library_creation?(plate)].all?
end