Sha256: a9c15b86b2df83cce31243889339bbd89dacaf5beeb1b5cba0fb1fc9871a14a3

Contents?: true

Size: 777 Bytes

Versions: 12

Compression:

Stored size: 777 Bytes

Contents

require 'rexml/document'

module DataMapper
  module Serializer
    module XML
      module REXML
        def self.new_document
          ::REXML::Document.new
        end

        def self.root_node(document, name, attrs = {})
          add_node(document.root || document, name, nil, attrs)
        end

        def self.add_node(parent, name, value, attrs = {})
          node = parent.add_element(name)

          attrs.each do |attr_name, attr_val|
            node.attributes[attr_name] = attr_val
          end

          node << ::REXML::Text.new(value.to_s) unless value.nil?
          node
        end

        def self.add_xml(parent, xml)
          parent.add(xml)
        end

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

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
sbf-dm-serializer-1.4.0 lib/dm-serializer/xml/rexml.rb
sbf-dm-serializer-1.3.0 lib/dm-serializer/xml/rexml.rb
sbf-dm-serializer-1.3.0.beta.2 lib/dm-serializer/xml/rexml.rb
sbf-dm-serializer-1.3.0.beta lib/dm-serializer/xml/rexml.rb
ardm-serializer-1.2.2 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.2.2 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.2.1 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.2.0 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.2.0.rc2 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.2.0.rc1 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.1.0 lib/dm-serializer/xml/rexml.rb
dm-serializer-1.1.0.rc3 lib/dm-serializer/xml/rexml.rb