Sha256: 8395d24816ef576f5eaec77f8f564c9bcdc7372d48fb74e7411820c01ab12967

Contents?: true

Size: 732 Bytes

Versions: 26

Compression:

Stored size: 732 Bytes

Contents

module DataMapper
  module Serialize
    module XMLSerializers
      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 {|attr_name, attr_val| node.attributes[attr_name] = attr_val}
          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

26 entries across 26 versions & 2 rubygems

Version Path
ixtlan-0.2.2 lib/dm-serializer/xml_serializers/rexml.rb
ixtlan-0.2.1 lib/dm-serializer/xml_serializers/rexml.rb
dm-serializer-0.10.2 lib/dm-serializer/xml_serializers/rexml.rb
ixtlan-0.2.0 lib/dm-serializer/xml_serializers/rexml.rb
dm-serializer-0.10.1 lib/dm-serializer/xml_serializers/rexml.rb
dm-serializer-0.10.0 lib/dm-serializer/xml_serializers/rexml.rb