Class: Unifig::Var

Inherits:
Object
  • Object
show all
Defined in:
lib/unifig/var.rb

Overview

A variable created after loading a configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameSymbol (readonly)

The variable name.

Returns:

  • (Symbol)

18
19
20
# File 'lib/unifig/var.rb', line 18

def name
  @name
end

#providerSymbol

The provider that supplied the value.

Returns:

  • (Symbol)

23
24
25
# File 'lib/unifig/var.rb', line 23

def provider
  @provider
end

#valueObject

The value of the variable.

Returns:

  • (Object)

31
32
33
# File 'lib/unifig/var.rb', line 31

def value
  @value
end

Instance Method Details

#methodSymbol

The name of the method this variable can be found using.

Returns:

  • (Symbol)

43
44
45
# File 'lib/unifig/var.rb', line 43

def method
  @method ||= name.to_s.downcase.tr('-', '_').to_sym
end

#required?Boolean

Returns whether or not this is a required variable.

Returns:

  • (Boolean)

55
56
57
58
59
60
61
62
# File 'lib/unifig/var.rb', line 55

def required?
  return @required if defined?(@required)

  optional = env_config(:optional)
  optional = @config[:optional] if optional.nil?
  optional = false if optional.nil?
  @required = !optional
end