Class: Talis::Bibliography::Manifestation
- 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
-
#assets ⇒ Object
readonly
TODO: call assets route if not set.
-
#contributors ⇒ Object
readonly
Returns the value of attribute contributors.
-
#id ⇒ Object
Returns the value of attribute id.
-
#manifestation_data ⇒ Object
readonly
Returns the value of attribute manifestation_data.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Attributes included from OAuthService
#client_id, #client_secret, #oauth_host
Class Method Summary collapse
-
.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.
-
.get(request_id: new_req_id, id:) ⇒ Object
Fetch a single work by id.
Instance Method Summary collapse
-
#hydrate_relationships(included_resources) ⇒ Object
By default, the metatron client returns generic ResourceLink objects as the related resources.
-
#initialize(manifestation_data = nil) ⇒ Manifestation
constructor
A new instance of Manifestation.
Methods included from Talis::Bibliography
Methods inherited from Resource
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
#assets ⇒ Object (readonly)
TODO: call assets route if not set
85 86 87 |
# File 'lib/talis/bibliography/manifestation.rb', line 85 def assets @assets end |
#contributors ⇒ Object (readonly)
Returns the value of attribute contributors.
19 20 21 |
# File 'lib/talis/bibliography/manifestation.rb', line 19 def contributors @contributors end |
#id ⇒ Object
Returns the value of attribute id.
20 21 22 |
# File 'lib/talis/bibliography/manifestation.rb', line 20 def id @id end |
#manifestation_data ⇒ Object (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 |
#title ⇒ Object
Returns the value of attribute title.
20 21 22 |
# File 'lib/talis/bibliography/manifestation.rb', line 20 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
20 21 22 |
# File 'lib/talis/bibliography/manifestation.rb', line 20 def type @type end |
#work ⇒ Object (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
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
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
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 |