Module: WithEnv
Constant Summary collapse
- VERSION =
"1.1.0"
Instance Method Summary collapse
Instance Method Details
#with_env(env, &blk) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/with_env.rb', line 6 def with_env(env, &blk) before = ENV.to_h.dup env.each { |k, v| ENV[k] = v } yield ensure ENV.replace(before) end |
#without_env(*keys, &blk) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/with_env.rb', line 14 def without_env(*keys, &blk) before = ENV.to_h.dup keys.flatten.each { |k| ENV.delete(k) } yield ensure ENV.replace(before) end |