Puppet Function: percona_hash_sections

Defined in:
lib/puppet/parser/functions/percona_hash_sections.rb
Function type:
Ruby 3.x API

Overview

percona_hash_sections()Any

Detects all the used sections in a hash.

Returns:

  • (Any)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puppet/parser/functions/percona_hash_sections.rb', line 3

newfunction(:percona_hash_sections, :type => :rvalue, :doc => <<-EODOC

Detects all the used sections in a hash.

EODOC
) do |args|

  args = [args] unless args.is_a?(Array)
  unless args.length == 1
    raise(Puppet::ParseError, 'percona_hash_sections(): excepts a single argument.')
  end
  hash = args.shift
  unless hash.is_a?(Hash)
    raise(Puppet::ParseError, 'percona_hash_sections(): argument is not a hash.')
  end

  sections = []
  hash.each do |key,value|
    sections << value[:section] unless sections.include?(value[:section])
  end
  sections

end