lib/lutaml/model/xml_adapter/nokogiri_adapter.rb in lutaml-model-0.3.7 vs lib/lutaml/model/xml_adapter/nokogiri_adapter.rb in lutaml-model-0.3.8
- old
+ new
@@ -70,21 +70,22 @@
if element_rule == xml_mapping.content_mapping
text = element.send(xml_mapping.content_mapping.to)
text = text[curr_index] if text.is_a?(Array)
prefixed_xml.text text
- elsif attribute_def.collection?
+ elsif !value.nil? || element_rule.render_nil?
+ value = value[curr_index] if attribute_def.collection?
+
add_to_xml(
xml,
element_rule.prefix,
- value[curr_index],
- attribute_def,
- element_rule,
+ value,
+ options.merge(
+ attribute: attribute_def,
+ rule: element_rule,
+ ),
)
- elsif !value.nil? || element_rule.render_nil?
- add_to_xml(xml, element_rule.prefix, value, attribute_def,
- element_rule)
end
end
end
end
end
@@ -156,10 +157,10 @@
node.children.map do |child|
NokogiriElement.new(child, root_node: root_node)
end
end
- def build_attributes(node)
+ def build_attributes(node, _options = {})
attrs = node.attributes.transform_values(&:value)
attrs.merge(build_namespace_attributes(node))
end