module Instana::Snapshot::Deltable

@since 1.197.0

Public Instance Methods

delta(key, *rest, compute:, obj:, path: [key, *rest]) click to toggle source
# File lib/instana/snapshot/deltable.rb, line 8
def delta(key, *rest, compute:, obj:, path: [key, *rest])
  val = obj[key]
  return val if val == nil

  if rest.empty?
    @__delta ||= Hash.new(0)
    cache_key = path.join('.')
    old = @__delta[cache_key]
    @__delta[cache_key] = val

    return compute.call(old, val)
  end

  delta(*rest, compute: compute, obj: val, path: path)
end