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
@@ -103,14 +103,13 @@ end
|
||||
|
||||
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]
|
||||
@wrap_in_array = options[:_wrap_in_array]
|
||||
end
|
||||
attr_accessor :object, :context, :scope, :root, :meta_key, :meta
|
||||
attr_accessor :object, :context, :root, :meta_key, :meta
|
||||
|
||||
def json_key
|
||||
if root == true || root.nil?
|
||||
@@ -167,7 +166,7 @@ end
|
||||
|
||||
def build_serializer(association)
|
||||
object = send(association.name)
|
||||
association.build_serializer(object, context: context, scope: scope)
|
||||
association.build_serializer(object, context: context)
|
||||
end
|
||||
|
||||
def serialize(association)
|
||||
|
||||
Reference in New Issue
Block a user