@@ -273,15 +273,14 @@ def prune_bnodes(input, bnodes_to_clear)
273
273
def cleanup_preserve ( input )
274
274
case input
275
275
when Array
276
- # If, after replacement, an array contains only the value null remove the value, leaving an empty array.
277
- input . map { |o | cleanup_preserve ( o ) }
276
+ input . map! { |o | cleanup_preserve ( o ) }
278
277
when Hash
279
278
if input . key? ( '@preserve' )
280
279
# Replace with the content of `@preserve`
281
280
cleanup_preserve ( input [ '@preserve' ] . first )
282
281
else
283
- input . inject ( { } ) do |memo , ( k , v ) |
284
- memo . merge ( k => cleanup_preserve ( v ) )
282
+ input . transform_values do |v |
283
+ cleanup_preserve ( v )
285
284
end
286
285
end
287
286
else
@@ -298,10 +297,10 @@ def cleanup_null(input)
298
297
case input
299
298
when Array
300
299
# If, after replacement, an array contains only the value null remove the value, leaving an empty array.
301
- input . map { |o | cleanup_null ( o ) } . compact
300
+ input . map! { |o | cleanup_null ( o ) } . compact
302
301
when Hash
303
- input . inject ( { } ) do |memo , ( k , v ) |
304
- memo . merge ( k => cleanup_null ( v ) )
302
+ input . transform_values do |v |
303
+ cleanup_null ( v )
305
304
end
306
305
when '@null'
307
306
# If the value from the key-pair is @null, replace the value with null
0 commit comments