Method: Puppet::Type#title

Defined in:
lib/puppet/type.rb

#titleString

TODO:

it is somewhat confusing that if the name_var is a valid parameter, it is assumed to be the name_var called :name, but if it is a property, it uses the name_var. It is further confusing as Type in some respects supports multiple namevars.

Returns the title of this object, or its name if title was not explicitly set. If the title is not already set, it will be computed by looking up the #name_var and using that value as the title.

Returns:

  • (String)

    Returns the title of this object, or its name if title was not explicitly set.

Raises:

  • (??? devfail)

    if title is not set, and name_var can not be found.



2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
# File 'lib/puppet/type.rb', line 2568

def title
  unless @title
    if self.class.validparameter?(name_var)
      @title = self[:name]
    elsif self.class.validproperty?(name_var)
      @title = should(name_var)
    else
      devfail "Could not find namevar #{name_var} for #{self.class.name}"
    end
  end

  @title
end