Method: Resourceful::Serialize::Model#serialize
- Defined in:
- lib/resourceful/serialize.rb
#serialize(format, options) ⇒ Object
:call-seq:
serialize format, = {}, :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, ) raise "Must specify :attributes option" unless [:attributes] hash = self.to_serializable([:attributes]) root = self.class.to_s.underscore if format == :xml hash.send("to_#{format}", :root => root) else {root => hash}.send("to_#{format}") end end |