Class: Pipeline

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#alternative_workline_identifierObject

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_passArray, String

The plate types(s) for which to suggest library passing for this particular pipeline

Returns:

  • (Array, String)


36
37
38
# File 'app/models/pipeline.rb', line 36

def library_pass
  @library_pass
end

#nameString

The name of the pipeline. Currently used internally, but may get exposed to users in future.

Returns:

  • (String)

    Name of the pipeline



17
18
19
# File 'app/models/pipeline.rb', line 17

def name
  @name
end

#pipeline_groupObject



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

#relationshipsHash<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.

Returns:

  • (Hash<String>)

    Hash of parent (key) and child (value) relationships



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

Parameters:

  • labware

    On load of plate / tube pages, is a Sequencescape::Api::V2::Plate / Sequencescape::Api::V2::Tube

Returns:

  • (Boolean)

    returns true if labware meets the filter criteria or there are no filters



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

Returns:

  • (String)

    The purpose name



71
72
73
# File 'app/models/pipeline.rb', line 71

def child_for(purpose)
  relationships[purpose]
end

#filtersHash

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

Examples:

pipeline.filters = { 'request_type_key' => 'library_request', 'library_type' => ['Stndard', 'Other'] }

Returns:

  • (Hash)

    Filter options



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

Parameters:

  • purpose (String)

    The name of the purpose being queried

Returns:

  • (Boolean)

    True if it should suggest passing



80
81
82
# File 'app/models/pipeline.rb', line 80

def library_pass?(purpose)
  Array(library_pass).include?(purpose)
end