lib/jsonpath/enumerable.rb in jsonpath-0.8.5 vs lib/jsonpath/enumerable.rb in jsonpath-0.8.6
- old
+ new
@@ -82,16 +82,21 @@
yield node if process_function_or_literal(sub_path[1, sub_path.size - 1])
end
end
def yield_value(blk, context, key)
+ key = Integer(key) rescue key if key
case @mode
when nil
blk.call(key ? context[key] : context)
when :compact
- context.delete(key) if key && context[key].nil?
+ if key && context[key].nil?
+ key.is_a?(Integer) ? context.delete_at(key) : context.delete(key)
+ end
when :delete
- context.delete(key) if key
+ if key
+ key.is_a?(Integer) ? context.delete_at(key) : context.delete(key)
+ end
when :substitute
if key
context[key] = blk.call(context[key])
else
context.replace(blk.call(context[key]))