Sha256: 0c51092ada62f594666dfd9077eaac9f7427a63fd6f960b0277ab1376f7ff8f7
Contents?: true
Size: 1.38 KB
Versions: 30
Compression:
Stored size: 1.38 KB
Contents
require "lutaml/lutaml_path/document_wrapper" module Lutaml module Xml module LutamlPath class DocumentWrapper < ::Lutaml::LutamlPath::DocumentWrapper protected def serialize_document(document) serialize_to_hash(document) end def serialize_to_hash(object) hash = {} attribute_name = nil object.all_content.each do |mapping, content| if mapping == "content" attribute_name = object.class.xml_mapping.content.attribute.to_s hash[attribute_name] ||= [] hash[attribute_name] << content.strip unless content.strip&.empty? elsif content.is_a?(String) if object.class.attributes[mapping.attribute].collection? hash[mapping.name] ||= [] hash[mapping.name] << content.strip else hash[mapping.name] = content.strip end else if object.class.attributes[mapping.attribute].collection? hash[mapping.name] ||= [] hash[mapping.name] << serialize_to_hash(content) else hash[mapping.name] = serialize_to_hash(content) end end end hash[attribute_name] = hash[attribute_name].compact if attribute_name hash end end end end end
Version data entries
30 entries across 30 versions & 1 rubygems