Class: Aruba::Platforms::UnixEnvironmentVariables::UpdateAction

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

Overview

Update environment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(other_env, &block) ⇒ UpdateAction

Returns a new instance of UpdateAction.


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 11

def initialize(other_env, &block)
  @other_env = other_env

  to_hash = RUBY_VERSION >= '2' ? :to_h : :to_hash

  @other_env = @other_env.public_send(to_hash).each_with_object({}) { |(k, v), a| a[k] = v.to_s }

  @block = if block_given?
             block
           end
end

Instance Attribute Details

#blockObject (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_envObject (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


23
24
25
26
27
28
29
# File 'lib/aruba/platforms/unix_environment_variables.rb', line 23

def call(env)
  if block
    env.update(other_env, &block)
  else
    env.update(other_env)
  end
end