Class: Cocina::Models::Mapping::FromMods::HydrusDefaultTitleBuilder

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

Overview

Maps titles

Class Method Summary collapse

Class Method Details

.build(resource_element:, notifier:, require_title: 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



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cocina/models/mapping/from_mods/hydrus_default_title_builder.rb', line 12

def self.build(resource_element:, notifier:, require_title: nil)
  titles = resource_element.xpath('mods:titleInfo/mods:title[string-length() > 0]',
                                  mods: Description::DESC_METADATA_NS)

  if titles.empty?
    return [{ value: 'Hydrus' }] if resource_element.name != 'relatedItem'

    return []
  end

  Title.build(resource_element: resource_element, notifier: notifier)
end