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. rubocop:disable Metrics/ClassLength rubocop:disable Metrics/MethodLength

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



52
53
54
55
# File 'lib/sul_orcid_client/work_mapper.rb', line 52

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

Class Method Details

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



46
47
48
# File 'lib/sul_orcid_client/work_mapper.rb', line 46

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

Instance Method Details

#mapObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sul_orcid_client/work_mapper.rb', line 57

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