Class: Pipeline
- Inherits:
-
Object
- Object
- Pipeline
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/pipeline.rb
Overview
A Pipeline is a series of steps that may be performed to complete a request. Steps are represented as a series of parent-child relationships reflecting transfer from one labware type to another. While Limber allows users to deviate from a pipeline, the series of steps specified defines the suggested ‘green’ route.
Instance Attribute Summary collapse
-
#alternative_workline_identifier ⇒ Object
Plate purpose that could be use as an alternative workline identifier in the barcode top right field when there are more than one ancestors that are Stock plates.
-
#library_pass ⇒ Array, String
The plate types(s) for which to suggest library passing for this particular pipeline.
-
#name ⇒ String
The name of the pipeline.
- #pipeline_group ⇒ Object
-
#relationships ⇒ Hash<String>
Hash of parent => child relationships.
Instance Method Summary collapse
-
#active_for?(labware) ⇒ Boolean
Checks if a piece of labware meets the filter criteria for a pipeline If there are no filter criteria, the pipeline could be active for any labware.
-
#child_for(purpose) ⇒ String
Returns the suggested child purpose for the provided parent.
-
#filters ⇒ Hash
The filters that will be used to identify whether a plate belongs to a particular pipeline Keys should be attributes on request (eg. library_type) whereas values are either an array of acceptable values, or a single acceptable value.
- #filters=(filters) ⇒ Object
-
#library_pass?(purpose) ⇒ Boolean
Returns true if the pipeline suggest library passing for the given purpose.
Instance Attribute Details
#alternative_workline_identifier ⇒ Object
Plate purpose that could be use as an alternative workline identifier in the barcode top right field when there are more than one ancestors that are Stock plates
46 47 48 |
# File 'app/models/pipeline.rb', line 46 def alternative_workline_identifier @alternative_workline_identifier end |
#library_pass ⇒ Array, String
The plate types(s) for which to suggest library passing for this particular pipeline
36 37 38 |
# File 'app/models/pipeline.rb', line 36 def library_pass @library_pass end |
#name ⇒ String
The name of the pipeline. Currently used internally, but may get exposed to users in future.
17 18 19 |
# File 'app/models/pipeline.rb', line 17 def name @name end |
#pipeline_group ⇒ Object
19 20 21 22 |
# File 'app/models/pipeline.rb', line 19 def pipeline_group # When no group is provided, default pipeline group to the pipeline name @pipeline_group ||= name end |
#relationships ⇒ Hash<String>
Hash of parent => child relationships. Indicates the steps which form part of this pipeline. Be aware, that this will restrict you to one child type per parent, per pipeline. Currently branching pipelines can be represented as two separate pipelines.
42 43 44 |
# File 'app/models/pipeline.rb', line 42 def relationships @relationships end |
Instance Method Details
#active_for?(labware) ⇒ Boolean
Checks if a piece of labware meets the filter criteria for a pipeline If there are no filter criteria, the pipeline could be active for any labware
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/pipeline.rb', line 52 def active_for?(labware) return true if filters.blank? labware.active_requests.any? do |request| # For each attribute (eg. library_type) check that the matching property # on request is included in the list of permitted values. filters.all? do |request_attribute, permitted_values| permitted_values.include? request.public_send(request_attribute) end end end |
#child_for(purpose) ⇒ String
Returns the suggested child purpose for the provided parent
71 72 73 |
# File 'app/models/pipeline.rb', line 71 def child_for(purpose) relationships[purpose] end |
#filters ⇒ Hash
The filters that will be used to identify whether a plate belongs to a particular pipeline Keys should be attributes on request (eg. library_type) whereas values are either an array of acceptable values, or a single acceptable value
30 31 32 |
# File 'app/models/pipeline.rb', line 30 def filters @filters || {} end |
#filters=(filters) ⇒ Object
64 65 66 67 |
# File 'app/models/pipeline.rb', line 64 def filters=(filters) # Convert any singlular values to an array to provide a consistent interface @filters = filters.transform_values { |value| Array(value) } end |
#library_pass?(purpose) ⇒ Boolean
Returns true if the pipeline suggest library passing for the given purpose
80 81 82 |
# File 'app/models/pipeline.rb', line 80 def library_pass?(purpose) Array(library_pass).include?(purpose) end |