Module: Braid::Operations

Extended by:
T::Sig
Defined in:
lib/braid/operations.rb,
lib/braid/operations_lite.rb

Defined Under Namespace

Modules: VersionControl Classes: Git, GitCache, LocalChangesPresent, MergeError, Proxy, ShellExecutionError, UnknownRevision, VersionTooLow

Class Method Summary collapse

Methods included from T::Sig

sig

Class Method Details

.with_modified_environment(dict, &blk) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/braid/operations_lite.rb', line 24

def self.with_modified_environment(dict, &blk)
  orig_dict = T.let({}, T::Hash[String, T.nilable(String)])
  dict.each { |name, value|
    orig_dict[name] = ENV[name]
    ENV[name] = value
  }
  begin
    yield
  ensure
    orig_dict.each { |name, orig_value|
      ENV[name] = orig_value
    }
  end
end