class Puppet::Generate::Models::Type::Type

A model for Puppet resource types.

Attributes

capability[R]

Gets the capability member attribute of the type

doc[R]

Gets the doc string of the type.

isomorphic[R]

Gets the isomorphic member attribute of the type

name[R]

Gets the name of the type as a Puppet string literal.

parameters[R]

Gets the parameters of the type.

properties[R]

Gets the properties of the type.

title_patterns[R]

Gets the title patterns of the type

Public Class Methods

new(type) click to toggle source

Initializes a type model. @param type [Puppet::Type] The Puppet type to model. @return [void]

   # File lib/puppet/generate/models/type/type.rb
34 def initialize(type)
35   @name = Puppet::Pops::Types::StringConverter.convert(type.name.to_s, '%p')
36   @doc = type.doc.strip
37   @properties = type.properties.map { |p| Property.new(p) }
38   @parameters = type.parameters.map do |name|
39     Property.new(type.paramclass(name))
40   end
41   sc = Puppet::Pops::Types::StringConverter.singleton
42   @title_patterns = Hash[type.title_patterns.map do |mapping|
43     [
44       sc.convert(mapping[0], '%p'),
45       sc.convert(mapping[1].map do |names|
46         next if names.empty?
47         raise Puppet::Error, _('title patterns that use procs are not supported.') unless names.size == 1
48         names[0].to_s
49       end, '%p')
50     ]
51   end]
52   @isomorphic = type.isomorphic?
53   # continue to emit capability as false when rendering the ERB
54   # template, so that pcore modules generated prior to puppet7 can be
55   # read by puppet7 and vice-versa.
56   @capability = false
57 end

Public Instance Methods

render(template) click to toggle source
   # File lib/puppet/generate/models/type/type.rb
59 def render(template)
60   template.result(binding)
61 end