Module: DataMapper::Serialize::XMLSerializers::LibXML
- Defined in:
- lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb
Class Method Summary collapse
- .add_node(parent, name, value, attrs = {}) ⇒ Object
- .new_document ⇒ Object
- .root_node(doc, name, attrs = {}) ⇒ Object
Class Method Details
.add_node(parent, name, value, attrs = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb', line 18 def self.add_node(parent, name, value, attrs = {}) value_str = value.to_s unless value.nil? node = ::LibXML::XML::Node.new(name, value_str) attrs.each do |attr_name, attr_val| node[attr_name] = attr_val end parent << node end |
.new_document ⇒ Object
5 6 7 |
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb', line 5 def self.new_document ::LibXML::XML::Document.new end |
.root_node(doc, name, attrs = {}) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb', line 9 def self.root_node(doc, name, attrs = {}) root = ::LibXML::XML::Node.new(name) attrs.each do |attr_name, attr_val| root[attr_name] = attr_val end doc.root.nil? ? doc.root = root : doc.root << root root end |