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

Version Path
dm-serializer-1.1.0.rc2 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.1.0.rc1 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.3 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.2 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.1 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.2 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.1 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0.pre5 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0.pre4 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0.pre3 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.0 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0.pre2 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.4.0.pre lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.0.rc3 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.3.0 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.0.rc2 lib/dm-serializer/xml_serializers/nokogiri.rb
dm-serializer-1.0.0.rc1 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.2.4 lib/dm-serializer/xml_serializers/nokogiri.rb
ixtlan-0.2.3 lib/dm-serializer/xml_serializers/nokogiri.rb