Module: BobTheHelper::Environment
- Included in:
- Command
- Defined in:
- lib/bob_the_helper/environment.rb
Instance Method Summary collapse
-
#isolated_environment(variables) { ... } ⇒ Object
Set environment variable for code block.
Instance Method Details
#isolated_environment(variables) { ... } ⇒ Object
Set environment variable for code block
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bob_the_helper/environment.rb', line 11 def isolated_environment(variables, &block) #backup old_env = ENV.to_hash #change env ENV.update variables block_result = block.call #cleanup ENV.clear #install backuped information ENV.update old_env block_result end |