Method: Resourceful::Serialize::Model#serialize

Defined in:
lib/resourceful/serialize.rb

#serialize(format, options) ⇒ Object

:call-seq:

serialize format, options = {}, :attributes => [ ... ]

See the module documentation for Serialize for details.



111
112
113
114
115
116
117
118
119
120
# File 'lib/resourceful/serialize.rb', line 111

def serialize(format, options)
  raise "Must specify :attributes option" unless options[:attributes]
  hash = self.to_serializable(options[:attributes])
  root = self.class.to_s.underscore
  if format == :xml
    hash.send("to_#{format}", :root => root)
  else
    {root => hash}.send("to_#{format}")
  end
end