Sha256: 211bb6b0ecd0c9ab31d18daaecdb31002a1ffee87927192a24a55b8f0ce2b682
Contents?: true
Size: 831 Bytes
Versions: 44
Compression:
Stored size: 831 Bytes
Contents
# frozen_string_literal: true module Cocina module Models module Mapping module FromMods # Helper class: checks and fixes status: primary class Primary # @params [Nokogiri::XML::NodeSet] node_set # @params [String] type the value of a node's type attribute we are concerned with 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 end end end end end
Version data entries
44 entries across 44 versions & 1 rubygems