Class: StateChanger::Base Abstract

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
app/models/state_changer/base.rb

Overview

This class is abstract.

This class should not be used directly

Note:

This initial StateChanger classes have been derived from the behaviour originally in the corresponding PlatePurpose. This has built up organically over time, and I (JG) don’t believe we actually depend on a lot of the differences in behaviour.

Abstract class for StateChangers, should not be used directly A state changer is designed to handle the transition of a piece of Labware from one state to another. Typically this involved: - Updating the transfer request into and out of the receptacles - Potentially failing the associated requests Usage as of 2021-03-21 Class Used Last used StateChanger::MxTube 43758 2021-03-23 StateChanger::StandardPlate 121793 2021-03-23 StateChanger::InputPlate 14 2021-03-02 StateChanger::InitialStockTube 30823 2021-03-23 StateChanger::StockTube 5650 2021-03-11 StateChanger::QcableLibraryPlate 213 2018-08-16 StateChanger::QcableLabware 3020 2021-03-21 StateChanger::StockMxTube 111 2018-08-20 # Removed

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#labwareLabware

The labware to update the state of

Returns:

  • (Labware)

    The labware to update the state of



40
41
42
# File 'app/models/state_changer/base.rb', line 40

def labware
  @labware
end

#userUser

The user performing the action that led to the state change

Returns:

  • (User)

    The user performing the action that led to the state change



44
45
46
# File 'app/models/state_changer/base.rb', line 44

def user
  @user
end

Instance Method Details

#associated_request_target_stateObject

Returns the state to transition associated requests to. If this returns nil the state changer should not transition the outer requests



66
67
68
# File 'app/models/state_changer/base.rb', line 66

def associated_request_target_state
  map_target_state_to_associated_request_state[target_state]
end

#contentsnil, Array<String>

Returns Array of well locations to update, leave nil or empty for ALL wells.

Returns:

  • (nil, Array<String>)

    Array of well locations to update, leave nil or empty for ALL wells



50
# File 'app/models/state_changer/base.rb', line 50

attribute :contents, default: nil

#customer_accepts_responsibilityBoolean

Returns The customer proceeded against advice and will still be charged in the the event of a failure.

Returns:

  • (Boolean)

    The customer proceeded against advice and will still be charged in the the event of a failure



54
# File 'app/models/state_changer/base.rb', line 54

attribute :customer_accepts_responsibility, :boolean, default: false

#map_target_state_to_associated_request_stateHash<String,String>

Maps the #target_state of the StateChanger to the target state of the associated requests. By default, StateChangers will not transition outer requests if the result of this mapping is nil.

Returns:

  • (Hash<String,String>)

    Hash indexed by target state, mapping to the desired transition of outer requests.



35
# File 'app/models/state_changer/base.rb', line 35

class_attribute :map_target_state_to_associated_request_state

#target_stateString

Returns String representing the state to transition to.

Returns:

  • (String)

    String representing the state to transition to



47
# File 'app/models/state_changer/base.rb', line 47

attribute :target_state, :string

#update_labware_stateVoid

Updates the state of the labware to the target state. The basic implementation does this by updating all of the TransferRequest instances to the state specified. If #contents is blank then the change is assumed to relate to all wells of the plate, otherwise only the selected ones are updated.

Returns:

  • (Void)

Raises:

  • (NotImplementedError)


60
61
62
# File 'app/models/state_changer/base.rb', line 60

def update_labware_state
  raise NotImplementedError
end