Class: Dor::Services::Client::SDR

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/sdr.rb

Overview

API calls that are about preserved objects

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:, object_identifier:) ⇒ SDR

Returns a new instance of SDR.

Parameters:

  • object_identifier (String)

    the pid for the object



11
12
13
14
# File 'lib/dor/services/client/sdr.rb', line 11

def initialize(connection:, version:, object_identifier:)
  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Method Details

#current_versionInteger

Gets the current version number for the object

Returns:

  • (Integer)

    the current version

Raises:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dor/services/client/sdr.rb', line 20

def current_version
  xml = current_version_response
  begin
    doc = Nokogiri::XML xml
    raise if doc.root.name != 'currentVersion'

    return Integer(doc.text)
  rescue StandardError
    raise MalformedResponse, "Unable to parse XML from current_version API call: #{xml}"
  end
end