Class: Dor::Workflow::Response::Workflows

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/workflow/response/workflows.rb

Overview

The response from asking the server about all workflows for an item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml:) ⇒ Workflows

Returns a new instance of Workflows.



8
9
10
# File 'lib/dor/workflow/response/workflows.rb', line 8

def initialize(xml:)
  @xml = xml
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



28
29
30
# File 'lib/dor/workflow/response/workflows.rb', line 28

def xml
  @xml
end

Instance Method Details

#errors_for(version:) ⇒ Array<String>

Returns a list of errors for any process for the current version

Returns:

  • (Array<String>)

    returns a list of errors for any process for the current version



23
24
25
26
# File 'lib/dor/workflow/response/workflows.rb', line 23

def errors_for(version:)
  ng_xml.xpath("//workflow/process[@version='#{version}' and @status='error']/@errorMessage")
        .map(&:text)
end

#pidObject



12
13
14
# File 'lib/dor/workflow/response/workflows.rb', line 12

def pid
  ng_xml.at_xpath('/workflows/@objectId').text
end

#workflowsObject



16
17
18
19
20
# File 'lib/dor/workflow/response/workflows.rb', line 16

def workflows
  @workflows ||= ng_xml.xpath('/workflows/workflow').map do |node|
    Workflow.new(xml: node.to_xml)
  end
end