add class attribute :root to ArraySerializer

You can now set the default behavior for Array serialization in a
single place
This commit is contained in:
Tee Parham
2012-07-14 21:44:23 -06:00
parent 56824f055b
commit 0832e42917
3 changed files with 47 additions and 5 deletions

View File

@@ -29,11 +29,18 @@ module ActiveModel
# Active Model Array Serializer
#
# It serializes an array checking if each element that implements
# It serializes an Array, checking if each element that implements
# the +active_model_serializer+ method.
#
# To disable serialization of root elements, in an initializer:
#
# ActiveModel::ArraySerializer.root = false
#
class ArraySerializer
attr_reader :object, :options
class_attribute :root
def initialize(object, options={})
@object, @options = object, options
end