Puppet Function: facts::group_by

Defined in:
lib/puppet/functions/facts/group_by.rb
Function type:
Ruby 4.x API

Overview

facts::group_by(Iterable $collection, Callable &$block)Hash

A simple wrapper of the ruby’s group_by function.

Parameters:

  • collection (Iterable)
  • &block (Callable)

Returns:

  • (Hash)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet/functions/facts/group_by.rb', line 4

Puppet::Functions.create_function(:'facts::group_by') do
  dispatch :native_group_by do
    param 'Iterable', :collection
    block_param
    return_type 'Hash'
  end

  def native_group_by(collection, &block)
    collection.group_by(&block)
  end
end