lib/cocina/models/mapping/from_mods/event.rb in cocina-models-0.98.1 vs lib/cocina/models/mapping/from_mods/event.rb in cocina-models-0.99.0
- old
+ new
@@ -419,27 +419,25 @@
}.compact
cocina_desc_val[:source] = source if source.present?
cocina_desc_val
end
- # rubocop:disable Metrics/CyclomaticComplexity
def build_structured_date(date_nodes)
return if date_nodes.blank?
common_attribs = common_date_attributes(date_nodes)
remove_dup_key_date_from_end_point(date_nodes)
dates = date_nodes.map do |node|
next if node.text.blank? && node.attributes.empty?
new_node = node.deep_dup
- new_node.remove_attribute('encoding') if common_attribs[:encoding].present? || node[:encoding]&.size&.zero?
- new_node.remove_attribute('qualifier') if common_attribs[:qualifier].present? || node[:qualifier]&.size&.zero?
+ new_node.remove_attribute('encoding') if common_attribs[:encoding].present? || node[:encoding]&.empty?
+ new_node.remove_attribute('qualifier') if common_attribs[:qualifier].present? || node[:qualifier]&.empty?
build_date(new_node)
end
{ structuredValue: dates }.merge(common_attribs).compact
end
- # rubocop:enable Metrics/CyclomaticComplexity
# Per Arcadia, keyDate should only appear once in an originInfo.
# If keyDate is on a date of type point and is on both the start and end points, then
# it should be removed from the end point
def remove_dup_key_date_from_end_point(date_nodes)