Class: Dor::Services::Response::Workflows

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/services/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.

Parameters:

  • xml (Nokogiri::XML)

    Nokogiri XML document showing all workflows



11
12
13
# File 'lib/dor/services/response/workflows.rb', line 11

def initialize(xml:)
  @xml = xml
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



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

def xml
  @xml
end

Instance Method Details

#errors_for(version:) ⇒ Array<String>

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

Returns:

  • (Array<String>)

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



26
27
28
# File 'lib/dor/services/response/workflows.rb', line 26

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

#pidObject



15
16
17
# File 'lib/dor/services/response/workflows.rb', line 15

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

#workflowsObject



19
20
21
22
23
# File 'lib/dor/services/response/workflows.rb', line 19

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