File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
activemodel/lib/active_model
activesupport/lib/active_support Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -256,7 +256,8 @@ def initialize_dup(other) # :nodoc:
256
256
end
257
257
258
258
def as_json ( options = { } ) # :nodoc:
259
- options [ :except ] = [ *options [ :except ] , "mutations_from_database" , "mutations_before_last_save" ]
259
+ except = [ *options [ :except ] , "mutations_from_database" , "mutations_before_last_save" ]
260
+ options = options . merge except : except
260
261
super ( options )
261
262
end
262
263
Original file line number Diff line number Diff line change @@ -165,7 +165,8 @@ def as_json(options = nil) # :nodoc:
165
165
class Array
166
166
def as_json ( options = nil ) # :nodoc:
167
167
if options
168
- map { |v | v . as_json ( options . dup ) }
168
+ options = options . dup . freeze unless options . frozen?
169
+ map { |v | v . as_json ( options ) }
169
170
else
170
171
map { |v | v . as_json }
171
172
end
@@ -189,7 +190,8 @@ def as_json(options = nil) # :nodoc:
189
190
190
191
result = { }
191
192
if options
192
- subset . each { |k , v | result [ k . to_s ] = v . as_json ( options . dup ) }
193
+ options = options . dup . freeze unless options . frozen?
194
+ subset . each { |k , v | result [ k . to_s ] = v . as_json ( options ) }
193
195
else
194
196
subset . each { |k , v | result [ k . to_s ] = v . as_json }
195
197
end
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def initialize(options = nil)
36
36
# Encode the given object into a JSON string
37
37
def encode ( value )
38
38
unless options . empty?
39
- value = value . as_json ( options . dup )
39
+ value = value . as_json ( options . dup . freeze )
40
40
end
41
41
json = stringify ( jsonify ( value ) )
42
42
You can’t perform that action at this time.
0 commit comments