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

Defined in:
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/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

.add_xml(parent, xml) ⇒ Object



20
21
22
# File 'lib/dm-serializer/xml_serializers/rexml.rb', line 20

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

.new_documentObject



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

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

.output(doc) ⇒ Object



24
25
26
# File 'lib/dm-serializer/xml_serializers/rexml.rb', line 24

def self.output(doc)
  doc.to_s
end

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



9
10
11
# File '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