Module: Fig::EnvironmentVariables
- Included in:
- CaseInsensitive, CaseSensitive
- Defined in:
- lib/fig/environment_variables.rb,
lib/fig/environment_variables/case_sensitive.rb,
lib/fig/environment_variables/case_insensitive.rb
Overview
Abstract manager of a set of environment variables.
Defined Under Namespace
Classes: CaseInsensitive, CaseSensitive
Instance Method Summary
collapse
Instance Method Details
#empty? ⇒ Boolean
11
12
13
|
# File 'lib/fig/environment_variables.rb', line 11
def empty?
return @variables.empty?
end
|
#initialize(variables_override = nil) ⇒ Object
7
8
9
|
# File 'lib/fig/environment_variables.rb', line 7
def initialize(variables_override = nil)
@variables = variables_override || get_system_environment_variables
end
|
#keys ⇒ Object
15
16
17
|
# File 'lib/fig/environment_variables.rb', line 15
def keys
return @variables.keys
end
|
#with_environment ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/fig/environment_variables.rb', line 19
def with_environment
original_environment = {}
original_environment.merge!(ENV.to_hash)
begin
set_system_environment_variables(@variables)
yield
ensure
ENV.clear
set_system_environment_variables(original_environment)
end
return
end
|