Method: Puppet::Type#set_default

Defined in:
lib/puppet/type.rb

#set_default(attr) ⇒ void

TODO:

comment says “For any parameters or properties that have defaults and have not yet been set, set them now. This method can be handed a list of attributes, and if so it will only set defaults for those attributes.”

TODO:

Needs a better explanation, and investigation about the claim an array can be passed (it is passed to self.class.attrclass to produce a class on which a check is made if it has a method class :default (does not seem to support an array…

This method returns an undefined value.



851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# File 'lib/puppet/type.rb', line 851

def set_default(attr)
  klass = self.class.attrclass(attr)
  return unless klass
  # TODO this is not a necessary check, as we define a class level attr_reader
  return unless klass.method_defined?(:default)
  return if @parameters.include?(klass.name)

  parameter = newattr(klass.name)
  return unless parameter

  value = parameter.default
  if value and !value.nil?
    parameter.value = value
  else
    @parameters.delete(parameter.name)
  end
end