Class: StateChanger::Base Abstract
- Inherits:
-
Object
- Object
- StateChanger::Base
- Includes:
- ActiveModel::Attributes, ActiveModel::Model
- Defined in:
- app/models/state_changer/base.rb
Overview
This class should not be used directly
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
Direct Known Subclasses
QcableLabware, QcableLibraryPlate, StandardPlate, TubeBase, TubeRack
Instance Attribute Summary collapse
-
#labware ⇒ Labware
The labware to update the state of.
-
#user ⇒ User
The user performing the action that led to the state change.
Instance Method Summary collapse
-
#associated_request_target_state ⇒ Object
Returns the state to transition associated requests to.
-
#contents ⇒ nil, Array<String>
Array of well locations to update, leave nil or empty for ALL wells.
-
#customer_accepts_responsibility ⇒ Boolean
The customer proceeded against advice and will still be charged in the the event of a failure.
-
#map_target_state_to_associated_request_state ⇒ Hash<String,String>
Maps the #target_state of the StateChanger to the target state of the associated requests.
-
#target_state ⇒ String
String representing the state to transition to.
-
#update_labware_state ⇒ Void
Updates the state of the labware to the target state.
Instance Attribute Details
#labware ⇒ Labware
The labware to update the state of
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/state_changer/base.rb', line 40 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#user ⇒ User
The user performing the action that led to the state change
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/state_changer/base.rb', line 44 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
Instance Method Details
#associated_request_target_state ⇒ Object
Returns the state to transition associated requests to. If this returns nil the state changer should not transition the outer requests
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/state_changer/base.rb', line 66 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#contents ⇒ nil, Array<String>
Returns Array of well locations to update, leave nil or empty for ALL wells.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/state_changer/base.rb', line 50 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#customer_accepts_responsibility ⇒ Boolean
Returns The customer proceeded against advice and will still be charged in the the event of a failure.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/models/state_changer/base.rb', line 54 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#map_target_state_to_associated_request_state ⇒ Hash<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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/state_changer/base.rb', line 35 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#target_state ⇒ String
Returns String representing the state to transition to.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/state_changer/base.rb', line 47 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |
#update_labware_state ⇒ Void
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.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/state_changer/base.rb', line 60 do # NOTE: The following attribute is not required for Microarray Genotyping. # I think this might be broken and suggests that there should be separate classes for project: one for # next-gen sequencing that includes this attribute in it's metadata, and one for microarray genotyping # that doesn't. include ProjectManager::Associations include BudgetDivision::Associations custom_attribute(:project_cost_code, required: true) custom_attribute(:funding_comments) custom_attribute(:collaborators) custom_attribute(:external_funding_source) custom_attribute(:sequencing_budget_cost_centre) custom_attribute(:project_funding_model, in: PROJECT_FUNDING_MODELS) custom_attribute(:gt_committee_tracking_id) before_validation do |record| record.project_cost_code = nil if record.project_cost_code.blank? record.project_funding_model = nil if record.project_funding_model.blank? end end |