Module: ROXML::InstanceMethods

Defined in:
lib/roxml.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#to_xml(name = self.class.tag_name) ⇒ Object

Returns an XML object representing this object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/roxml.rb', line 21

def to_xml(name = self.class.tag_name)
  XML::Node.create(name.to_s).tap do |root|
    self.class.roxml_attrs.each do |attr|
      ref = attr.to_ref(self)
      value = ref.to_xml(self)
      unless value.nil?
        ref.update_xml(root, value)
      end
    end
  end
end