Class: Opto::Resolvers::Variable

Inherits:
Opto::Resolver show all
Defined in:
lib/opto/resolvers/variable.rb

Overview

Find a value of another variable.

Hint should be a name of another variable

Instance Attribute Summary

Attributes inherited from Opto::Resolver

#hint, #option

Instance Method Summary collapse

Methods inherited from Opto::Resolver

for, inherited, #initialize, origin, #origin, resolvers

Constructor Details

This class inherits a constructor from Opto::Resolver

Instance Method Details

#resolveObject

Raises:

  • (ArgumentError)

8
9
10
11
12
13
14
# File 'lib/opto/resolvers/variable.rb', line 8

def resolve
  raise ArgumentError, "Variable name not set" if hint.nil?
  if option.group.nil? || option.group.option(hint).nil?
    raise RuntimeError, "Variable #{hint} not declared"
  end
  option.value_of(hint)
end