Add docs to serializable

This commit is contained in:
Santiago Pastorino 2013-05-16 15:53:39 -07:00
parent aaa08c25ef
commit f179a27ed7

View File

@ -1,4 +1,27 @@
require 'active_support/core_ext/object/to_json'
module ActiveModel
# Enable classes to Classes including this module to serialize themselves by implementing a serialize method and an options method.
#
# Example:
#
# require 'active_model_serializers'
#
# class MySerializer
# include ActiveModel::Serializable
#
# def initialize
# @options = {}
# end
#
# attr_reader :options
#
# def serialize
# { a: 1 }
# end
# end
#
# puts MySerializer.new.to_json
module Serializable
def as_json(args={})
if root = args[:root] || options[:root]