Class: Aruba::Platforms::UnixEnvironmentVariables::UpdateAction
- Inherits:
-
Object
- Object
- Aruba::Platforms::UnixEnvironmentVariables::UpdateAction
- Defined in:
- lib/aruba/platforms/unix_environment_variables.rb
Overview
Update environment
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#other_env ⇒ Object
readonly
Returns the value of attribute other_env.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(other_env, &block) ⇒ UpdateAction
constructor
A new instance of UpdateAction.
Constructor Details
#initialize(other_env, &block) ⇒ UpdateAction
Returns a new instance of UpdateAction.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 11 def initialize(other_env, &block) @other_env = other_env @other_env = if RUBY_VERSION <= '1.9.3' # rubocop:disable Style/EachWithObject @other_env.to_hash.inject({}) { |a, (k, v)| a[k] = v.to_s; a } # rubocop:enable Style/EachWithObject else @other_env.to_h.each_with_object({}) { |(k, v), a| a[k] = v.to_s } end @block = if block_given? block end end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
9 10 11 |
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 9 def block @block end |
#other_env ⇒ Object (readonly)
Returns the value of attribute other_env.
9 10 11 |
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 9 def other_env @other_env end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 27 def call(env) if block env.update(other_env, &block) else env.update(other_env) end end |