Class: Cocina::Models::Mapping::FromMods::NameBuilder

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

Overview

Maps a name

Constant Summary collapse

UNCITED_DESCRIPTION =
Cocina::Models::Mapping::ToMods::NameWriter::UNCITED_DESCRIPTION
TYPE_FOR_ROLES =
Cocina::Models::Mapping::FromMods::Contributor::ROLES.merge('event' => 'event').freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_elements:, notifier:) ⇒ NameBuilder

Returns a new instance of NameBuilder.



20
21
22
23
# File 'lib/cocina/models/mapping/from_mods/name_builder.rb', line 20

def initialize(name_elements:, notifier:)
  @name_elements = name_elements
  @notifier = notifier
end

Class Method Details

.build(name_elements:, notifier:) ⇒ 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



16
17
18
# File 'lib/cocina/models/mapping/from_mods/name_builder.rb', line 16

def self.build(name_elements:, notifier:)
  new(name_elements: name_elements, notifier: notifier).build
end

Instance Method Details

#buildObject



25
26
27
28
29
30
31
# File 'lib/cocina/models/mapping/from_mods/name_builder.rb', line 25

def build
  if name_elements.size == 1
    build_name(name_elements.first)
  else
    build_parallel
  end
end