class RubyYacht::Hook::EnvironmentVariableBehavior

This class provides a behavior for setting an environment variable in the image.

Public Class Methods

new(name, proc) click to toggle source

This initializer creates the behavior.

### Parameters

  • **name: String** The name of the environment variable to create.

  • **proc: Proc** The proc for generating the value for the

    environment variable.
# File lib/ruby_yacht/dsl/hook.rb, line 238
def initialize(name, proc)
  @name = name
  @proc = proc
  @context = self
end

Public Instance Methods

dockerfile_command() click to toggle source

The command that should be run in a Dockerfile for this behavior.

# File lib/ruby_yacht/dsl/hook.rb, line 250
def dockerfile_command
  value = self.value
  return nil unless value
  "ENV #{@name} #{value}"
end
shell_command() click to toggle source

The command that should be run in a shell script for this behavior.

# File lib/ruby_yacht/dsl/hook.rb, line 257
def shell_command
  value = self.value
  return nil unless value
  "export #{@name}=\"#{value}\""
end
value() click to toggle source

The value for the environment variable.

# File lib/ruby_yacht/dsl/hook.rb, line 245
def value
  context.instance_eval(&@proc)
end