From f179a27ed793aa3b9a93dd666364134a18f43edf Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 16 May 2013 15:53:39 -0700 Subject: [PATCH] Add docs to serializable --- lib/active_model/serializable.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/active_model/serializable.rb b/lib/active_model/serializable.rb index 47300530..cf1cbaa7 100644 --- a/lib/active_model/serializable.rb +++ b/lib/active_model/serializable.rb @@ -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]