mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Nest scope under context option
This commit is contained in:
committed by
Santiago Pastorino
parent
8bd2542ed2
commit
0d8ef2b165
@@ -14,15 +14,14 @@ module ActiveModel
|
||||
|
||||
def initialize(object, options={})
|
||||
@object = object
|
||||
@context = options[:context]
|
||||
@scope = options[:scope]
|
||||
@context = options[:context] || {}
|
||||
@root = options.fetch(:root, self.class._root)
|
||||
@meta_key = options[:meta_key] || :meta
|
||||
@meta = options[@meta_key]
|
||||
@each_serializer = options[:each_serializer]
|
||||
@resource_name = options[:resource_name]
|
||||
end
|
||||
attr_accessor :object, :context, :scope, :root, :meta_key, :meta
|
||||
attr_accessor :object, :context, :root, :meta_key, :meta
|
||||
|
||||
def json_key
|
||||
if root.nil?
|
||||
@@ -34,7 +33,7 @@ module ActiveModel
|
||||
|
||||
def serializer_for(item)
|
||||
serializer_class = @each_serializer || Serializer.serializer_for(item) || DefaultSerializer
|
||||
serializer_class.new(item, context: context, scope: scope)
|
||||
serializer_class.new(item, context: context)
|
||||
end
|
||||
|
||||
def serializable_object
|
||||
|
||||
Reference in New Issue
Block a user