Class: Datacite::Mapping::FromCocina::Attributes
- Inherits:
-
Object
- Object
- Datacite::Mapping::FromCocina::Attributes
- Defined in:
- lib/datacite/mapping/from_cocina/attributes.rb
Overview
Transform the Cocina::Models::DRO to a DataCite request attributes payload
Instance Attribute Summary collapse
-
#cocina_object ⇒ Object
readonly
Returns the value of attribute cocina_object.
Class Method Summary collapse
-
.build ⇒ Hash
Hash of DataCite attributes, conforming to the DataCite API Schema.
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(cocina_object:) ⇒ Attributes
constructor
A new instance of Attributes.
Constructor Details
#initialize(cocina_object:) ⇒ Attributes
Returns a new instance of Attributes.
17 18 19 20 21 22 |
# File 'lib/datacite/mapping/from_cocina/attributes.rb', line 17 def initialize(cocina_object:) @cocina_object = cocina_object # Set the time zone Time.zone = 'Pacific Time (US & Canada)' end |
Instance Attribute Details
#cocina_object ⇒ Object (readonly)
Returns the value of attribute cocina_object.
24 25 26 |
# File 'lib/datacite/mapping/from_cocina/attributes.rb', line 24 def cocina_object @cocina_object end |
Class Method Details
.build ⇒ Hash
Returns Hash of DataCite attributes, conforming to the DataCite API Schema.
13 14 15 |
# File 'lib/datacite/mapping/from_cocina/attributes.rb', line 13 def self.build(...) new(...).call end |
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/datacite/mapping/from_cocina/attributes.rb', line 28 def call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength { event: 'publish', url: description.purl, identifiers: Identifiers.build(identification:), titles: Titles.build(description:), publisher: { name: 'Stanford Digital Repository' }, # per DataCite schema publicationYear: publication_year, subjects: Subject.build(description:), dates: Date.build(cocina_object:), language: 'en', types: Types.build(description:), alternateIdentifiers: AlternateIdentifiers.build(description:), relatedIdentifiers: , rightsList: RightsList.build(access:), descriptions: Descriptions.build(description:), relatedItems: , schemaVersion: 'http://datacite.org/schema/kernel-4' }.merge(ContributorAttributes.build(description:)).compact end |