Sha256: b70c614ec9fe7089d545faec5f6dcea86b721ec4e58daf698ee3f6fde92d1f6c

Contents?: true

Size: 382 Bytes

Versions: 1

Compression:

Stored size: 382 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

def with_env(new_env)
  env_to_reset = ENV.select { |k, _| new_env.key?(k) }
  keys_to_delete = new_env.keys - ENV.keys
  new_env.each_pair { |k, v| ENV[k] = v }
  yield
ensure
  env_to_reset.each_pair { |k, v| ENV[k] = v }
  keys_to_delete.each { |k| ENV.delete(k) }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-common-0.17.0 lib/opentelemetry/common/test_helpers.rb