Sha256: e7cc6205244883bdd9f7811988599361b654645b51ad909f8f562bb03c1225f5
Contents?: true
Size: 975 Bytes
Versions: 26
Compression:
Stored size: 975 Bytes
Contents
module DataMapper module Serialize module XMLSerializers module Nokogiri def self.new_document ::Nokogiri::XML::Document.new end def self.root_node(doc, name, attrs = {}) root = ::Nokogiri::XML::Node.new(name, doc) attrs.each do |attr_name, attr_val| root[attr_name] = attr_val end doc.root.nil? ? doc.root = root : doc.root << root root end def self.add_node(parent, name, value, attrs = {}) node = ::Nokogiri::XML::Node.new(name, parent.document) node << ::Nokogiri::XML::Text.new(value.to_s, parent.document) unless value.nil? attrs.each {|attr_name, attr_val| node[attr_name] = attr_val } parent << node node end def self.add_xml(parent, xml) parent << xml.root end def self.output(doc) doc.root.to_s end end end end end
Version data entries
26 entries across 26 versions & 2 rubygems