Class: Hiera::RecursiveLookup

### Home Classes Methods

### In Files

- lib/hiera/recursive_lookup.rb

### Parent

Object

### Methods

- ::new
- #current_value
- #lookup

### Class/Module Index

Quicksearch

- Hiera
- Hiera::Backend
- Hiera::Backend::Json_backend
- Hiera::Backend::Yaml_backend
- Hiera::Config
- Hiera::Console_logger
- Hiera::FallbackLogger
- Hiera::Filecache
- Hiera::Noop_logger
- Hiera::Puppet_logger
- Hiera::RecursiveLookup
- Hiera::Util

No matching classes.

# Hiera::RecursiveLookup

Allow for safe recursive lookup of values during variable interpolation.

@api private

### Public Class Methods

new(scope, extra_data) click to toggle source

    # File lib/hiera/recursive_lookup.rb, line 5
    def initialize(scope, extra_data)
      @seen = []
      @scope = scope
      @extra_data = extra_data
    end

### Public Instance Methods

current_value() click to toggle source

    # File lib/hiera/recursive_lookup.rb, line 21
    def current_value
      name = @seen.last

      scope_val = @scope[name]
      if scope_val.nil? || scope_val == :undefined
        @extra_data[name]
      else
        scope_val
      end
    end

lookup(name, &block) click to toggle source

    # File lib/hiera/recursive_lookup.rb, line 11
    def lookup(name, &block)
      if @seen.include?(name)
        raise Exception, "Interpolation loop detected in [#{@seen.join(', ')}]"
      end
      @seen.push(name)
      ret = yield(current_value)
      @seen.pop
      ret
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.