@@ -15,17 +15,18 @@ def initialize(object, options={})
15
15
@object = object
16
16
@scope = options [ :scope ]
17
17
@root = options . fetch ( :root , self . class . _root )
18
- @polymorphic = options . fetch ( :polymorphic , false )
18
+ @polymorphic = options . fetch ( :polymorphic , false )
19
19
@meta_key = options [ :meta_key ] || :meta
20
20
@meta = options [ @meta_key ]
21
21
@each_serializer = options [ :each_serializer ]
22
22
@resource_name = options [ :resource_name ]
23
23
@only = options [ :only ] ? Array ( options [ :only ] ) : nil
24
24
@except = options [ :except ] ? Array ( options [ :except ] ) : nil
25
+ @context = options [ :context ]
25
26
@namespace = options [ :namespace ]
26
27
@key_format = options [ :key_format ] || options [ :each_serializer ] . try ( :key_format )
27
28
end
28
- attr_accessor :object , :scope , :root , :meta_key , :meta , :key_format
29
+ attr_accessor :object , :scope , :root , :meta_key , :meta , :key_format , :context
29
30
30
31
def json_key
31
32
key = root . nil? ? @resource_name : root
@@ -35,7 +36,7 @@ def json_key
35
36
36
37
def serializer_for ( item )
37
38
serializer_class = @each_serializer || Serializer . serializer_for ( item , namespace : @namespace ) || DefaultSerializer
38
- serializer_class . new ( item , scope : scope , key_format : key_format , only : @only , except : @except , polymorphic : @polymorphic , namespace : @namespace )
39
+ serializer_class . new ( item , scope : scope , key_format : key_format , context : @context , only : @only , except : @except , polymorphic : @polymorphic , namespace : @namespace )
39
40
end
40
41
41
42
def serializable_object ( options = { } )
@@ -66,7 +67,7 @@ def embedded_in_root_associations
66
67
private
67
68
68
69
def instrumentation_keys
69
- [ :object , :scope , :root , :meta_key , :meta , :each_serializer , :resource_name , :key_format ]
70
+ [ :object , :scope , :root , :meta_key , :meta , :each_serializer , :resource_name , :key_format , :context ]
70
71
end
71
72
end
72
73
end
0 commit comments