@@ -273,15 +273,14 @@ def prune_bnodes(input, bnodes_to_clear)
273273 def cleanup_preserve ( input )
274274 case input
275275 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 ) }
278277 when Hash
279278 if input . key? ( '@preserve' )
280279 # Replace with the content of `@preserve`
281280 cleanup_preserve ( input [ '@preserve' ] . first )
282281 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 )
285284 end
286285 end
287286 else
@@ -298,10 +297,10 @@ def cleanup_null(input)
298297 case input
299298 when Array
300299 # 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
302301 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 )
305304 end
306305 when '@null'
307306 # If the value from the key-pair is @null, replace the value with null
0 commit comments