Class: Serialize::Xml

Inherits:
Format
  • Object
show all
Defined in:
lib/serialize/xml.rb

Instance Method Summary collapse

Methods inherited from Format

#initialize

Constructor Details

This class inherits a constructor from Serialize::Format

Instance Method Details

#render(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/serialize/xml.rb', line 5

def render(*args)
  # args are empty unless called through
  # another to_xml call
  options = unless args.empty?
    args.first
  else
    subject = collection? ? object.first.class.name : object.class.name
    name = subject.include?("::") ? subject.split("::").last : subject
    name = name.titleize.downcase
    name = name.pluralize if collection?
    { :root => name }
  end

  content.to_xml(options)
end