class Hiera::PuppetFunction

Provides the base class for the puppet functions hiera, hiera_array, hiera_hash, and hiera_include. The actual function definitions will call ::init_dispatch and override the #merge_type and #post_lookup methods.

@see hiera_array.rb, hiera_include.rb under lib/puppet/functions for sample usage

Public Instance Methods

hiera_block1(scope, key, &default_block) click to toggle source
# File lib/hiera/puppet_function.rb, line 55
def hiera_block1(scope, key, &default_block)
  common(scope, key, nil, default_block)
end
hiera_block2(scope, key, override, &default_block) click to toggle source
# File lib/hiera/puppet_function.rb, line 59
def hiera_block2(scope, key, override, &default_block)
  common(scope, key, override, default_block)
end
hiera_no_default(scope, key) click to toggle source
# File lib/hiera/puppet_function.rb, line 45
def hiera_no_default(scope, key)
  post_lookup(scope, key, lookup(scope, key, nil, nil))
end
hiera_splat(scope, args) click to toggle source
# File lib/hiera/puppet_function.rb, line 41
def hiera_splat(scope, args)
  hiera(scope, *args)
end
hiera_with_default(scope, key, default, override = nil) click to toggle source
# File lib/hiera/puppet_function.rb, line 49
def hiera_with_default(scope, key, default, override = nil)
  undefined = (@@undefined_value ||= Object.new)
  result = lookup(scope, key, undefined, override)
  post_lookup(scope, key, result.equal?(undefined) ? default : result)
end
lookup(scope, key, default, override) click to toggle source
# File lib/hiera/puppet_function.rb, line 71
def lookup(scope, key, default, override)
  HieraPuppet.lookup(key, default, scope, override, merge_type)
end
merge_type() click to toggle source
# File lib/hiera/puppet_function.rb, line 75
def merge_type
  :priority
end
post_lookup(scope, key, result) click to toggle source
# File lib/hiera/puppet_function.rb, line 79
def post_lookup(scope, key, result)
  result
end

Public Class Methods

init_dispatch() click to toggle source
# File lib/hiera/puppet_function.rb, line 9
def self.init_dispatch
  dispatch :hiera_splat do
    scope_param
    param 'Tuple[String, Any, Any, 1, 3]', :args
  end

  dispatch :hiera_no_default do
    scope_param
    param 'String',:key
  end

  dispatch :hiera_with_default do
    scope_param
    param 'String',:key
    param 'Any',   :default
    optional_param 'Any',   :override
  end

  dispatch :hiera_block1 do
    scope_param
    param 'String',              :key
    block_param 'Callable[1,1]', :default_block
  end

  dispatch :hiera_block2 do
    scope_param
    param 'String',              :key
    param 'Any',                 :override
    block_param 'Callable[1,1]', :default_block
  end
end