Class: Workflow

Inherits:
ApplicationRecord show all
Defined in:
app/models/workflow.rb

Overview

A workflow describes a series of Tasks which are processed as part of taking a Batch through a Pipeline

Instance Method Summary collapse

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Instance Method Details

#assetsObject


23
24
25
# File 'app/models/workflow.rb', line 23

def assets
  []
end

#batch_limit?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'app/models/workflow.rb', line 15

def batch_limit?
  item_limit.present?
end

#deep_copy(suffix = '_dup', skip_pipeline = false) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/workflow.rb', line 27

def deep_copy(suffix = '_dup', skip_pipeline = false)
  dup.tap do |new_workflow|
    ActiveRecord::Base.transaction do
      new_workflow.name = new_workflow.name + suffix
      new_workflow.tasks = tasks.map do |task|
        new_task = task.dup
        new_task.descriptors = task.descriptors.map(&:dup)
        new_task
      end
      new_workflow.pipeline = nil
      new_workflow.save!

      # copy of the pipeline
      unless skip_pipeline
        new_workflow.pipeline = pipeline.dup
        new_workflow.pipeline.request_types = pipeline.request_types
        new_workflow.pipeline.name += suffix
        new_workflow.pipeline.save!
      end
    end
  end
end

#source_is_internal?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'app/models/workflow.rb', line 19

def source_is_internal?
  locale == 'Internal'
end