Simplify Foreman::Process#with_environment

This commit is contained in:
brainopia
2012-01-22 08:57:09 +04:00
parent 158c184f8c
commit df043e60d8

View File

@@ -59,12 +59,11 @@ private
end
def with_environment(environment)
old_env = ENV.each_pair.inject({}) { |h,(k,v)| h.update(k => v) }
environment.each { |k,v| ENV[k] = v }
ret = yield
ENV.clear
old_env.each { |k,v| ENV[k] = v}
ret
original = ENV.to_hash
ENV.update environment
yield
ensure
ENV.replace original
end
end