class Bundler::EnvironmentPreserver
def backup
-
(Hash)
-
def backup env = @original.clone @keys.each do |key| value = env[key] original_value = env[@prefix + key] if !value.nil? && !value.empty? && original_value.nil? env[@prefix + key] = value end end env end
def initialize(env, keys)
-
keys
(Array
) -- -
env
(ENV
) --
def initialize(env, keys) @original = env.to_hash @keys = keys @prefix = "BUNDLE_ORIG_" end
def restore
-
(Hash)
-
def restore env = @original.clone @keys.each do |key| value_original = env[@prefix + key] unless value_original.nil? || value_original.empty? env[key] = value_original env.delete(@prefix + key) end end env end