Class: Cocina::Models::Mapping::FromMods::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/from_mods/form.rb

Overview

Maps relevant MODS physicalDescription, typeOfResource and genre from descMetadata to cocina form rubocop:disable Metrics/ClassLength

Constant Summary collapse

H2_GENRE_TYPE_PREFIX =

NOTE: H2 is the first case of structured form (genre/typeOfResource) values we’re implementing

'H2 '
H2_SOURCE_LABEL =
'Stanford self-deposit resource types'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_element:, description_builder:) ⇒ Form

Returns a new instance of Form.



22
23
24
25
# File 'lib/cocina/models/mapping/from_mods/form.rb', line 22

def initialize(resource_element:, description_builder:)
  @resource_element = resource_element
  @notifier = description_builder.notifier
end

Class Method Details

.build(resource_element:, description_builder:, purl: nil) ⇒ Hash

Returns a hash that can be mapped to a cocina model.

Parameters:

Returns:

  • (Hash)

    a hash that can be mapped to a cocina model



18
19
20
# File 'lib/cocina/models/mapping/from_mods/form.rb', line 18

def self.build(resource_element:, description_builder:, purl: nil)
  new(resource_element: resource_element, description_builder: description_builder).build
end

Instance Method Details

#buildObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/cocina/models/mapping/from_mods/form.rb', line 27

def build
  forms = []
  add_genre(forms)
  add_types(forms)
  add_physical_descriptions(forms)
  add_subject_cartographics(forms)
  add_etd_resource_type(forms)
  Primary.adjust(forms, 'genre', notifier, match_type: true)
  Primary.adjust(forms, 'resource type', notifier, match_type: true)
end