Sha256: d02fad06319c702583f701d9928976449d122d302ab265696cc5bf7946c3edb1

Contents?: true

Size: 953 Bytes

Versions: 11

Compression:

Stored size: 953 Bytes

Contents

module DataMapper
  module Serialize
    module XMLSerializers
      module LibXML
        def self.new_document
          ::LibXML::XML::Document.new
        end

        def self.root_node(doc, name, attrs = {})
          root = ::LibXML::XML::Node.new(name)
          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 = {})
          value_str = value.to_s unless value.nil?
          node = ::LibXML::XML::Node.new(name, value_str)
          attrs.each do |attr_name, attr_val|
            node[attr_name] = attr_val
          end
          parent << node
          node
        end

        def self.add_xml(parent, xml)
          parent << xml.root.copy(true)
        end

        def self.output(doc)
          doc.root.to_s
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dm-serializer-1.1.0.rc2 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.1.0.rc1 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.2 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.1 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.0 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.0.rc3 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.0.rc2 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-1.0.0.rc1 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-0.10.2 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-0.10.1 lib/dm-serializer/xml_serializers/libxml.rb
dm-serializer-0.10.0 lib/dm-serializer/xml_serializers/libxml.rb