Class: LyberCore::Workflow
- Inherits:
-
Object
- Object
- LyberCore::Workflow
- Defined in:
- lib/lyber_core/workflow.rb
Overview
This encapsulates the workflow operations that lyber-core does
Instance Attribute Summary collapse
-
#object_client ⇒ Object
readonly
Returns the value of attribute object_client.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#workflow_name ⇒ Object
readonly
Returns the value of attribute workflow_name.
Instance Method Summary collapse
- #complete!(status, elapsed, note) ⇒ Object
-
#context ⇒ Hash
Any workflow context associated with the workflow.
- #error!(error_msg, error_text) ⇒ Object
-
#initialize(object_client:, workflow_name:, process:) ⇒ Workflow
constructor
A new instance of Workflow.
- #lane_id ⇒ String?
-
#object_workflow ⇒ Dor::Services::Client::ObjectWorkflow
For druid/workflow/step on which this instance was initialized.
-
#process_response ⇒ Dor::Services::Response::Process
For druid/workflow/step on which this instance was initialized.
- #retrying! ⇒ Object
- #start!(note) ⇒ Object
- #status ⇒ Object
-
#workflow_process ⇒ Dor::Services::Client::Process
For druid/workflow/step on which this instance was initialized.
-
#workflow_response ⇒ Dor::Services::Response::Workflow
For druid/workflow/step on which this instance was initialized.
Constructor Details
#initialize(object_client:, workflow_name:, process:) ⇒ Workflow
Returns a new instance of Workflow.
6 7 8 9 10 |
# File 'lib/lyber_core/workflow.rb', line 6 def initialize(object_client:, workflow_name:, process:) @object_client = object_client @workflow_name = workflow_name @process = process end |
Instance Attribute Details
#object_client ⇒ Object (readonly)
Returns the value of attribute object_client.
62 63 64 |
# File 'lib/lyber_core/workflow.rb', line 62 def object_client @object_client end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
62 63 64 |
# File 'lib/lyber_core/workflow.rb', line 62 def process @process end |
#workflow_name ⇒ Object (readonly)
Returns the value of attribute workflow_name.
62 63 64 |
# File 'lib/lyber_core/workflow.rb', line 62 def workflow_name @workflow_name end |
Instance Method Details
#complete!(status, elapsed, note) ⇒ Object
36 37 38 |
# File 'lib/lyber_core/workflow.rb', line 36 def complete!(status, elapsed, note) workflow_process.update(status:, elapsed:, note:) end |
#context ⇒ Hash
Returns any workflow context associated with the workflow.
49 50 51 |
# File 'lib/lyber_core/workflow.rb', line 49 def context @context ||= process_response.context end |
#error!(error_msg, error_text) ⇒ Object
44 45 46 |
# File 'lib/lyber_core/workflow.rb', line 44 def error!(error_msg, error_text) workflow_process.update_error(error_msg:, error_text:) end |
#lane_id ⇒ String?
58 59 60 |
# File 'lib/lyber_core/workflow.rb', line 58 def lane_id @lane_id ||= process_response.lane_id end |
#object_workflow ⇒ Dor::Services::Client::ObjectWorkflow
Returns for druid/workflow/step on which this instance was initialized.
13 14 15 |
# File 'lib/lyber_core/workflow.rb', line 13 def object_workflow object_client.workflow(workflow_name) end |
#process_response ⇒ Dor::Services::Response::Process
Returns for druid/workflow/step on which this instance was initialized.
28 29 30 |
# File 'lib/lyber_core/workflow.rb', line 28 def process_response workflow_response.process_for_recent_version(name: process) end |
#retrying! ⇒ Object
40 41 42 |
# File 'lib/lyber_core/workflow.rb', line 40 def workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil) end |
#start!(note) ⇒ Object
32 33 34 |
# File 'lib/lyber_core/workflow.rb', line 32 def start!(note) workflow_process.update(status: 'started', elapsed: 1.0, note:) end |
#status ⇒ Object
53 54 55 |
# File 'lib/lyber_core/workflow.rb', line 53 def status @status ||= workflow_process.status end |
#workflow_process ⇒ Dor::Services::Client::Process
Returns for druid/workflow/step on which this instance was initialized.
18 19 20 |
# File 'lib/lyber_core/workflow.rb', line 18 def workflow_process object_workflow.process(process) end |
#workflow_response ⇒ Dor::Services::Response::Workflow
Returns for druid/workflow/step on which this instance was initialized.
23 24 25 |
# File 'lib/lyber_core/workflow.rb', line 23 def workflow_response object_workflow.find end |