Module: XmlFormatter

Defined in:
lib/xml_formatter.rb

Instance Method Summary collapse

Instance Method Details

#to_xml(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/xml_formatter.rb', line 2

def to_xml(options = {})
  options[:indent] ||= 2
  xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
  xml.instruct! unless options[:skip_instruct]
  xml.tag!(self.class.name.downcase.to_sym, self.attributes) do
    self.class.reflect_on_all_associations.to_a.each do |assoc|
      xml.tag!(assoc.name)
    end
  end
end