Class: SulOrcidClient::WorkMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/sul_orcid_client/work_mapper.rb

Overview

Note that this mapping is currently based on a description generated from an H2 work. However, it could be extended to more completely map descriptions.

Defined Under Namespace

Classes: WorkMapperError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, doi: nil) ⇒ WorkMapper

Returns a new instance of WorkMapper.

Parameters:

  • description (Cocina::Models::Description)

    to map

  • doi (String) (defaults to: nil)

    from identification.doi



16
17
18
19
# File 'lib/sul_orcid_client/work_mapper.rb', line 16

def initialize(description:, doi: nil)
  @description = description
  @doi = doi
end

Class Method Details

.map(description:, doi: nil) ⇒ Object



10
11
12
# File 'lib/sul_orcid_client/work_mapper.rb', line 10

def self.map(description:, doi: nil)
  new(description: description, doi: doi).map
end

Instance Method Details

#mapObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sul_orcid_client/work_mapper.rb', line 21

def map
  {
    title: map_title,
    "short-description": map_short_description,
    citation: map_citation,
    type: map_type,
    "publication-date": map_publication_date,
    "external-ids": map_external_ids,
    url: description.purl,
    contributors: map_contributors,
    "language-code": "en",
    country: {
      value: "US"
    }
  }.compact
end