Class: Datacite::Mapping::FromCocina::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/datacite/mapping/from_cocina/subject.rb

Overview

Transform the Cocina::Models::Description subjects attributes to the DataCite subjects attributes

see https://support.datacite.org/reference/dois-2#put_dois-id

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:) ⇒ Subject

Returns a new instance of Subject.



16
17
18
# File 'lib/datacite/mapping/from_cocina/subject.rb', line 16

def initialize(description:)
  @description = description
end

Class Method Details

.buildNilClass, Array<Hash>

HTTP PUT request to DataCite

Parameters:

  • description (Cocina::Models::Description)

Returns:

  • (NilClass, Array<Hash>)

    list of DataCite subjects attributes, conforming to the expectations of



12
13
14
# File 'lib/datacite/mapping/from_cocina/subject.rb', line 12

def self.build(...)
  new(...).call
end

Instance Method Details

#callNilClass, Array<Hash>

HTTP PUT request to DataCite

Returns:

  • (NilClass, Array<Hash>)

    list of DataCite subjects attributes, conforming to the expectations of



22
23
24
25
26
27
28
29
# File 'lib/datacite/mapping/from_cocina/subject.rb', line 22

def call
  return if description&.subject.blank?

  results = description.subject.map do |cocina_subject|
    subject(cocina_subject)
  end
  results.compact.presence
end