Class: Cocina::Models::Mapping::ToMods::ModsWriter

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

Overview

Maps description resource from cocina to MODS XML

Class Method Summary collapse

Class Method Details

.write(xml:, description:, druid:, id_generator: IdGenerator.new) ⇒ Object

Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cocina/models/mapping/to_mods/mods_writer.rb', line 12

def self.write(xml:, description:, druid:, id_generator: IdGenerator.new)
  # ID Generator makes sure that different writers create unique altRepGroups and nameTitleGroups.
  if description.title
    Title.write(xml: xml, titles: description.title, contributors: description.contributor,
                id_generator: id_generator)
  end
  Contributor.write(xml: xml, contributors: description.contributor, titles: description.title,
                    id_generator: id_generator)
  Form.write(xml: xml, forms: description.form, id_generator: id_generator)
  Language.write(xml: xml, languages: description.language)
  Note.write(xml: xml, notes: description.note, id_generator: id_generator)
  Subject.write(xml: xml, subjects: description.subject, forms: description.form,
                id_generator: id_generator)
  Event.write(xml: xml, events: description.event, id_generator: id_generator)
  Identifier.write(xml: xml, identifiers: description.identifier, id_generator: id_generator)
  Access.write(xml: xml, access: description.access,
               purl: description.respond_to?(:purl) ? description.purl : nil)
  AdminMetadata.write(xml: xml, admin_metadata: description.)
  RelatedResource.write(xml: xml, related_resources: description.relatedResource, druid: druid,
                        id_generator: id_generator)
  Geographic.write(xml: xml, geos: description.geographic, druid: druid) if description.respond_to?(:geographic)
end