Method: Puppet::Parameter#initialize

Defined in:
lib/puppet/parameter.rb

#initialize(resource: nil, value: nil, should: nil) ⇒ Parameter

Note:

A parameter should be created via the DSL method Type::newparam

Initializes the parameter with a required resource reference and optional attribute settings. The option ‘:resource` must be specified or an exception is raised. Any additional options passed are used to initialize the attributes of this parameter by treating each key in the `options` hash as the name of the attribute to set, and the value as the value to set.

Parameters:

  • Options, where ‘resource` is required

Raises:

  • If resource is not specified in the options hash.

API:

  • public



346
347
348
349
350
351
352
353
354
355
# File 'lib/puppet/parameter.rb', line 346

def initialize(resource: nil, value: nil, should: nil)
  if resource
    self.resource = resource
  else
    raise Puppet::DevError, _("No resource set for %{name}") % { name: self.class.name }
  end

  self.value = value if value
  self.should = should if should
end