Class: FPM::Cookery::Hiera::Instance

Inherits:
Hiera
  • Object
show all
Includes:
Defaults
Defined in:
lib/fpm/cookery/hiera.rb

Overview

Hiera subclass that wraps a recipe class

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Defaults

hiera_backends, hiera_config, hiera_datadir, hiera_hierarchy, hiera_logger

Constructor Details

#initialize(recipe, options = {}) ⇒ Instance

Expects a recipe class and a hash containing one key, :config.



18
19
20
21
22
23
24
25
# File 'lib/fpm/cookery/hiera.rb', line 18

def initialize(recipe, options = {})
  @recipe = recipe
  @scope = Scope.new(recipe)

  # For some reason, +Hiera+'s constructor expects a hash with just the
  # one key.
  super({ :config => hiera_config(options) })
end

Instance Attribute Details

#recipeObject (readonly)

Returns the value of attribute recipe.



15
16
17
# File 'lib/fpm/cookery/hiera.rb', line 15

def recipe
  @recipe
end

#scopeObject (readonly)

Returns the value of attribute scope.



15
16
17
# File 'lib/fpm/cookery/hiera.rb', line 15

def scope
  @scope
end

Instance Method Details

#lookup(key, default = nil, scope = self.scope, *rest) ⇒ Object Also known as: []

Provides a default scope, and attempts to look up the key both as a string and as a symbol.



29
30
31
# File 'lib/fpm/cookery/hiera.rb', line 29

def lookup(key, default = nil, scope = self.scope, *rest)
    super(key.to_s, default, scope, *rest)
end