Class: Datacite::Mapping::FromCocina::Types

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

Overview

Transform the Cocina::Models::Description form attributes to the DataCite types attributes

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:) ⇒ Types

Returns a new instance of Types.



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

def initialize(description:)
  @description = description
end

Class Method Details

.buildNilClass, Hash

to DataCite

Parameters:

  • description (Cocina::Models::Description)

Returns:

  • (NilClass, Hash)

    the DataCite types attributes, conforming to the expectations of HTTP PUT request



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

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

Instance Method Details

#callNilClass, Hash

to DataCite

Returns:

  • (NilClass, Hash)

    the DataCite types attributes, conforming to the expectations of HTTP PUT request



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

def call
  return unless resource_type_general || resource_type

  {
    resourceTypeGeneral: resource_type_general,
    resourceType: resource_type || ''
  }
end