Method: Puppet::Util::ClassGen#genmodule

Defined in:
lib/puppet/util/classgen.rb

#genmodule(name, options = {}, &block) ⇒ Module

Creates a new module.

Parameters:

  • name (String)

    the name of the generated module

  • options (Hash) (defaults to: {})

    hash with options

Options Hash (options):

  • :array (Array<Class>)

    if specified, the generated class is appended to this array

  • :attributes (Hash<{String => Object}>)

    a hash that is applied to the generated class by calling setter methods corresponding to this hash’s keys/value pairs. This is done before the given block is evaluated.

  • :block (Proc)

    a block to evaluate in the context of the class (this block can be provided this way, or as a normal yield block).

  • :constant (String) — default: name with first letter capitalized

    what to set the constant that references the generated class to.

  • :hash (Hash)

    a hash of existing classes that this class is appended to (name => class). This hash must be specified if the ‘:overwrite` option is set to `true`.

  • :overwrite (Boolean)

    whether an overwrite of an existing class should be allowed (requires also defining the ‘:hash` with existing classes as the test is based on the content of this hash). the capitalized name is appended and the result is set as the constant.

  • ('') (String)

    :prefix the constant prefix to prepend to the constant name referencing the generated class.

Returns:

  • (Module)

    the generated Module



57
58
59
# File 'lib/puppet/util/classgen.rb', line 57

def genmodule(name, options = {}, &block)
  genthing(name, Module, options, block)
end