Module: DataMapper::Serializer::XML::REXML
- Defined in:
- lib/dm-serializer/xml/rexml.rb
Class Method Summary collapse
- .add_node(parent, name, value, attrs = {}) ⇒ Object
- .add_xml(parent, xml) ⇒ Object
- .new_document ⇒ Object
- .output(doc) ⇒ Object
- .root_node(document, name, attrs = {}) ⇒ Object
Class Method Details
.add_node(parent, name, value, attrs = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dm-serializer/xml/rexml.rb', line 15 def self.add_node(parent, name, value, attrs = {}) node = parent.add_element(name) attrs.each do |attr_name, attr_val| node.attributes[attr_name] = attr_val end node << ::REXML::Text.new(value.to_s) unless value.nil? node end |
.add_xml(parent, xml) ⇒ Object
26 27 28 |
# File 'lib/dm-serializer/xml/rexml.rb', line 26 def self.add_xml(parent, xml) parent.add(xml) end |
.new_document ⇒ Object
7 8 9 |
# File 'lib/dm-serializer/xml/rexml.rb', line 7 def self.new_document ::REXML::Document.new end |
.output(doc) ⇒ Object
30 31 32 |
# File 'lib/dm-serializer/xml/rexml.rb', line 30 def self.output(doc) doc.to_s end |
.root_node(document, name, attrs = {}) ⇒ Object
11 12 13 |
# File 'lib/dm-serializer/xml/rexml.rb', line 11 def self.root_node(document, name, attrs = {}) add_node(document.root || document, name, nil, attrs) end |