Method: Puppet::Type.attrclass

Defined in:
lib/puppet/type.rb

.attrclass(name) ⇒ Class?

Returns the class associated with the given attribute name.

Parameters:

  • name (String)

    the name of the attribute to obtain the class for

Returns:

  • (Class, nil)

    the class for the given attribute, or nil if the name does not refer to an existing attribute



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/puppet/type.rb', line 133

def self.attrclass(name)
  @attrclasses ||= {}

  # We cache the value, since this method gets called such a huge number
  # of times (as in, hundreds of thousands in a given run).
  unless @attrclasses.include?(name)
    @attrclasses[name] = case attrtype(name)
                         when :property; @validproperties[name]
                         when :meta; @@metaparamhash[name]
                         when :param; @paramhash[name]
                         end
  end
  @attrclasses[name]
end