Simplify Foreman::Process#with_environment
This commit is contained in:
@@ -59,12 +59,11 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_environment(environment)
|
def with_environment(environment)
|
||||||
old_env = ENV.each_pair.inject({}) { |h,(k,v)| h.update(k => v) }
|
original = ENV.to_hash
|
||||||
environment.each { |k,v| ENV[k] = v }
|
ENV.update environment
|
||||||
ret = yield
|
yield
|
||||||
ENV.clear
|
ensure
|
||||||
old_env.each { |k,v| ENV[k] = v}
|
ENV.replace original
|
||||||
ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user