Module: DataMapper::Serialize::XMLSerializers::REXML

Defined in:
lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb

Class Method Summary collapse

Class Method Details

.add_node(parent, name, value, attrs = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb', line 13

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

.new_documentObject



5
6
7
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb', line 5

def self.new_document
  ::REXML::Document.new
end

.root_node(document, name, attrs = {}) ⇒ Object



9
10
11
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb', line 9

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