Module: ROXML::InstanceMethods::Conversions

Defined in:
lib/roxml.rb

Instance Method Summary collapse

Instance Method Details

#to_xml(name = nil) ⇒ Object

Returns a LibXML::XML::Node or a REXML::Element representing this object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/roxml.rb', line 78

def to_xml(name = nil)
  returning XML::Node.new_element(name || self.class.tag_name) do |root|
    self.class.roxml_attrs.each do |attr|
      ref = attr.to_ref(self)
      v = ref.to_xml
      unless v.nil?
        ref.update_xml(root, v)
      end
    end
  end
end