Sha256: 4ccedc491789cc898edf0faa54ca79086627b5e02a18e2299089a1414e32bcee

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
dm-serializer-0.9.9 lib/dm-serializer/xml_serializers/nokogiri.rb
mack-data_mapper-0.8.3 lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb
mack-data_mapper-0.8.3.1 lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb