Class: Talis::Bibliography::Manifestation

Inherits:
Resource show all
Extended by:
Forwardable, Talis::Bibliography, OAuthService
Defined in:
lib/talis/bibliography/manifestation.rb

Overview

Represents bibliographic manifestations API operations provided by the Metatron gem https://github.com/talis/metatron_rb

In order to perform remote operations, the client must be configured with a valid OAuth client that is allowed to query nodes:

Talis::Authentication.client_id = 'client_id'
Talis::Authentication.client_secret = 'client_secret'

Instance Attribute Summary collapse

Attributes included from OAuthService

#client_id, #client_secret, #oauth_host

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Talis::Bibliography

api_client

Methods inherited from Resource

handle_response, new_req_id

Constructor Details

#initialize(manifestation_data = nil) ⇒ Manifestation

Returns a new instance of Manifestation.



72
73
74
75
76
77
78
# File 'lib/talis/bibliography/manifestation.rb', line 72

def initialize(manifestation_data = nil)
  if manifestation_data.is_a? MetatronClient::ManifestationData
    parse_manifestation_data manifestation_data
  else
    @manifestation_data = MetatronClient::ManifestationData.new
  end
end

Instance Attribute Details

#assetsObject (readonly)

TODO: call assets route if not set



85
86
87
# File 'lib/talis/bibliography/manifestation.rb', line 85

def assets
  @assets
end

#contributorsObject (readonly)

Returns the value of attribute contributors.



19
20
21
# File 'lib/talis/bibliography/manifestation.rb', line 19

def contributors
  @contributors
end

#idObject

Returns the value of attribute id.



20
21
22
# File 'lib/talis/bibliography/manifestation.rb', line 20

def id
  @id
end

#manifestation_dataObject (readonly)

Returns the value of attribute manifestation_data.



19
20
21
# File 'lib/talis/bibliography/manifestation.rb', line 19

def manifestation_data
  @manifestation_data
end

#titleObject

Returns the value of attribute title.



20
21
22
# File 'lib/talis/bibliography/manifestation.rb', line 20

def title
  @title
end

#typeObject

Returns the value of attribute type.



20
21
22
# File 'lib/talis/bibliography/manifestation.rb', line 20

def type
  @type
end

#workObject (readonly)

Returns the value of attribute work.



19
20
21
# File 'lib/talis/bibliography/manifestation.rb', line 19

def work
  @work
end

Class Method Details

.find(request_id: new_req_id, opts: {}) ⇒ MetatronClient::ManifestationResultSet

Search for bibliographic manifestations

where manifestations are of type Talis::Bibliography::Manifestation, which are also available

directly via the Enumerable methods: each, find, find_all, first, last

Parameters:

Returns:

  • (MetatronClient::ManifestationResultSet)

    containing data and meta attributes. The structure is as follows:

    {
      data: [manifestation1, manifestation2, manifestation3],
      meta: { count: 3 }
      included: [contributor1]
    }
    

Raises:



42
43
44
45
46
47
48
49
50
51
# File 'lib/talis/bibliography/manifestation.rb', line 42

def find(request_id: new_req_id, opts: {})
  api_client(request_id).manifestation(token, opts)
                        .extend(ResultSet).hydrate
rescue MetatronClient::ApiError => error
  begin
    handle_response(error)
  rescue Talis::NotFoundError
    empty_result_set(MetatronClient::ManifestationResultSet, count: 0)
  end
end

.get(request_id: new_req_id, id:) ⇒ Object

Fetch a single work by id

Parameters:

  • request_id (String) (defaults to: new_req_id)

    (‘uuid’) unique ID for the remote request.

  • id (String)

    the ID of the work to fetch.

Returns:

  • Talis::Bibliography::Work or nil if the work cannot be found.

Raises:



61
62
63
64
65
66
67
68
69
# File 'lib/talis/bibliography/manifestation.rb', line 61

def get(request_id: new_req_id, id:)
  new api_client(request_id).get_manifestation(token, id).data
rescue MetatronClient::ApiError => error
  begin
    handle_response(error)
  rescue Talis::NotFoundError
    nil
  end
end

Instance Method Details

#hydrate_relationships(included_resources) ⇒ Object

By default, the metatron client returns generic ResourceLink objects as the related resources. When passed an array of Metatron::ResourceData objects, it will replace the ResourceLink objects with more appropriately typed objects

Parameters:

  • resources (Array)

    an array of Metatron::ResourceData objects



94
95
96
97
98
99
# File 'lib/talis/bibliography/manifestation.rb', line 94

def hydrate_relationships(included_resources)
  contributors.map! do |contributor|
    find_relationship_in_included(contributor,
                                  included_resources)
  end
end