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