Class: Cocina::Models::Mapping::ToMods::NameTitleGroup

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

Overview

Helpers for MODS nameTitleGroups.

Class Method Summary collapse

Class Method Details

.in_name_title_group?(contributor:, titles:) ⇒ boolean

Returns true if contributor part of name title group.

Returns:

  • (boolean)

    true if contributor part of name title group



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

def self.in_name_title_group?(contributor:, titles:)
  return false if contributor&.name.blank? || titles.blank?

  contrib_name_value_slices = Cocina::Models::Builders::NameTitleGroupBuilder.contributor_name_value_slices(contributor)
  Array(titles).each do |title|
    name_title_group_names = Cocina::Models::Builders::NameTitleGroupBuilder.build_title_values_to_contributor_name_values(title)&.values
    name_title_group_names.each do |name|
      return true if contrib_name_value_slices.include?(name)
    end
  end

  false
end