Class: Aruba::Platforms::LocalEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/platforms/local_environment.rb

Overview

Local environemnt

Wraps logic to make enviroment local and restorable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform) ⇒ LocalEnvironment

Returns a new instance of LocalEnvironment.



11
12
13
# File 'lib/aruba/platforms/local_environment.rb', line 11

def initialize(platform)
  @platform = platform
end

Instance Attribute Details

#platformObject (readonly)

Returns the value of attribute platform.



15
16
17
# File 'lib/aruba/platforms/local_environment.rb', line 15

def platform
  @platform
end

Instance Method Details

#call(env) { ... } ⇒ Object

Run in environment

Parameters:

  • env (Hash)

    The environment

Yields:

  • The block of code which should with local ENV



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/aruba/platforms/local_environment.rb', line 24

def call(env)
  old_env = platform.environment_variables.hash_from_env

  ENV.clear
  ENV.update env

  yield if block_given?
ensure
  ENV.clear
  ENV.update old_env
end