Class: Greenpeace::Configuration::Requirement

Inherits:
Object
  • Object
show all
Defined in:
lib/greenpeace/configuration/requirement.rb

Overview

Represents an environment requirement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options, environment) ⇒ Requirement

Returns a new instance of Requirement.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/greenpeace/configuration/requirement.rb', line 12

def initialize(key, options, environment)
  @environment = environment
  @key = Greenpeace::Configuration::Key.new(key)
  @type = Greenpeace::Configuration::Type.new(options, :type)
  @doc = Greenpeace::Configuration::Doc.new(options, :doc)
  @default = Greenpeace::Configuration::Default.new(
    @type,
    options,
    nil,
    :defaults)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/greenpeace/configuration/requirement.rb', line 10

def key
  @key
end

Instance Method Details

#identifierObject



24
25
26
# File 'lib/greenpeace/configuration/requirement.rb', line 24

def identifier
  @key.identifier
end

#valueObject



28
29
30
31
32
33
34
35
36
# File 'lib/greenpeace/configuration/requirement.rb', line 28

def value
  value = ENV[@key.env_identifier]

  if value.nil? || value.empty?
    try_with_environment_values
  else
    @type.convert(value)
  end
end