From 787b7cf24a2096233c107548be1c67d8692f61b3 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 15 May 2013 17:49:03 -0700 Subject: [PATCH] Document Associations --- lib/active_model/serializer/associations.rb | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/active_model/serializer/associations.rb b/lib/active_model/serializer/associations.rb index d647d816..cb3cb005 100644 --- a/lib/active_model/serializer/associations.rb +++ b/lib/active_model/serializer/associations.rb @@ -2,6 +2,28 @@ module ActiveModel class Serializer module Associations #:nodoc: class Base #:nodoc: + # name: The name of the association. + # + # options: A hash. These keys are accepted: + # + # value: The object we're associating with. + # + # serializer: The class used to serialize the association. + # + # embed: Define how associations should be embedded. + # - :objects # Embed associations as full objects. + # - :ids # Embed only the association ids. + # - :ids, :include => true # Embed the association ids and include objects in the root. + # + # include: Used in conjunction with embed :ids. Includes the objects in the root. + # + # root: Used in conjunction with include: true. Defines the key used to embed the objects. + # + # key: Key name used to store the ids in. + # + # embed_key: Method used to fetch ids. Defaults to :id. + # + # polymorphic: Is the association is polymorphic?. Values: true or false. def initialize(name, options={}, serializer_options={}) @name = name @object = options[:value]