Add @options back into serializers to maintain the functionality of render :json as noted in the docs

This functionality used to exist in v0.8.1. This adds the ability to
pass other options that will be usable in the serializer via the
options accessor.

This works by adding an attr_accessor for options so it is available
and is set by the remaining options in the provided options hash during
initialization.
This commit is contained in:
Jason Truluck
2013-11-12 12:57:31 -05:00
parent 127413ffde
commit a110df6caf
3 changed files with 20 additions and 2 deletions

View File

@@ -20,7 +20,7 @@ module ActiveModel
@each_serializer = options[:each_serializer]
@options = options.merge(root: nil)
end
attr_accessor :object, :root, :meta_key, :meta
attr_accessor :object, :root, :meta_key, :meta, :options
def json_key
if root.nil?