Class: Cocina::Models::Mapping::ToMods::Contributor

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/to_mods/contributor.rb

Overview

Maps contributors from cocina to MODS XML

Constant Summary collapse

NAME_TYPE =

one way mapping: MODS ‘corporate’ already maps to Cocina ‘organization’

Cocina::Models::Mapping::FromMods::Contributor::ROLES.invert.merge('event' => 'corporate').freeze
NAME_PART =
Cocina::Models::Mapping::FromMods::Contributor::NAME_PART.invert.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml:, contributors:, titles:, id_generator:) ⇒ Contributor

Returns a new instance of Contributor.



22
23
24
25
26
27
# File 'lib/cocina/models/mapping/to_mods/contributor.rb', line 22

def initialize(xml:, contributors:, titles:, id_generator:)
  @xml = xml
  @contributors = contributors
  @titles = titles
  @id_generator = id_generator
end

Class Method Details

.write(xml:, contributors:, titles:, id_generator:) ⇒ Object

NOTE: contributors in nameTitleGroups are output as part of Title.



18
19
20
# File 'lib/cocina/models/mapping/to_mods/contributor.rb', line 18

def self.write(xml:, contributors:, titles:, id_generator:)
  new(xml: xml, contributors: contributors, titles: titles, id_generator: id_generator).write
end

Instance Method Details

#writeObject

NOTE: contributors in nameTitleGroups are output as part of Title.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocina/models/mapping/to_mods/contributor.rb', line 30

def write
  Array(contributors)
    .reject do |contributor|
    NameTitleGroup.in_name_title_group?(contributor: contributor,
                                        titles: titles)
  end
    .each do |contributor|
    NameWriter.write(xml: xml, contributor: contributor,
                     id_generator: id_generator)
  end
end