Class: Cocina::Models::Mapping::FromMods::Primary
- Inherits:
-
Object
- Object
- Cocina::Models::Mapping::FromMods::Primary
- Defined in:
- lib/cocina/models/mapping/from_mods/primary.rb
Overview
Helper class: checks and fixes status: primary
Class Method Summary collapse
Class Method Details
.adjust(node_set, type, notifier, match_type: false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cocina/models/mapping/from_mods/primary.rb', line 11 def self.adjust(node_set, type, notifier, match_type: false) primary_node_set = node_set.select do |node| node[:status] == 'primary' && (!match_type || node[:type] == type) end return node_set if primary_node_set.size < 2 primary_node_set[1..].each { |node| node.delete(:status) } notifier.warn('Multiple marked as primary', { type: type }) node_set end |