Class: LyberCore::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/lyber_core/workflow.rb

Overview

This encapsulates the workflow operations that lyber-core does

Instance Method Summary collapse

Constructor Details

#initialize(workflow_service:, druid:, workflow_name:, process:) ⇒ Workflow

Returns a new instance of Workflow.



6
7
8
9
10
11
# File 'lib/lyber_core/workflow.rb', line 6

def initialize(workflow_service:, druid:, workflow_name:, process:)
  @workflow_service = workflow_service
  @druid = druid
  @workflow_name = workflow_name
  @process = process
end

Instance Method Details

#complete!(status, elapsed, note) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/lyber_core/workflow.rb', line 22

def complete!(status, elapsed, note)
  workflow_service.update_status(druid: druid,
                                 workflow: workflow_name,
                                 process: process,
                                 status: status,
                                 elapsed: elapsed,
                                 note: note)
end

#error!(error_msg, error_text) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/lyber_core/workflow.rb', line 31

def error!(error_msg, error_text)
  workflow_service.update_error_status(druid: druid,
                                       workflow: workflow_name,
                                       process: process,
                                       error_msg: error_msg,
                                       error_text: error_text)
end

#lane_idObject



45
46
47
# File 'lib/lyber_core/workflow.rb', line 45

def lane_id
  @lane_id ||= workflow_service.process(pid: druid, workflow_name: workflow_name, process: process).lane_id
end

#start!(note) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/lyber_core/workflow.rb', line 13

def start!(note)
  workflow_service.update_status(druid: druid,
                                 workflow: workflow_name,
                                 process: process,
                                 status: 'started',
                                 elapsed: 1.0,
                                 note: note)
end

#statusObject



39
40
41
42
43
# File 'lib/lyber_core/workflow.rb', line 39

def status
  @status ||= workflow_service.workflow_status(druid: druid,
                                               workflow: workflow_name,
                                               process: process)
end