Class: Puppet::Generate::Models::Type::Type
- Defined in:
- lib/puppet/generate/models/type/type.rb
Overview
A model for Puppet resource types.
Instance Attribute Summary collapse
-
#capability ⇒ Object
readonly
Gets the capability member attribute of the type.
-
#doc ⇒ Object
readonly
Gets the doc string of the type.
-
#isomorphic ⇒ Object
readonly
Gets the isomorphic member attribute of the type.
-
#name ⇒ Object
readonly
Gets the name of the type as a Puppet string literal.
-
#parameters ⇒ Object
readonly
Gets the parameters of the type.
-
#properties ⇒ Object
readonly
Gets the properties of the type.
-
#title_patterns ⇒ Object
readonly
Gets the title patterns of the type.
Instance Method Summary collapse
-
#initialize(type) ⇒ void
constructor
Initializes a type model.
- #render(template) ⇒ Object
Constructor Details
#initialize(type) ⇒ void
Initializes a type model.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/puppet/generate/models/type/type.rb', line 35 def initialize(type) @name = Puppet::Pops::Types::StringConverter.convert(type.name.to_s, '%p') @doc = type.doc.strip @properties = type.properties.map { |p| Property.new(p) } @parameters = type.parameters.map do |name| Property.new(type.paramclass(name)) end sc = Puppet::Pops::Types::StringConverter.singleton @title_patterns = type.title_patterns.to_h do |mapping| [ sc.convert(mapping[0], '%p'), sc.convert(mapping[1].map do |names| next if names.empty? raise Puppet::Error, _('title patterns that use procs are not supported.') unless names.size == 1 names[0].to_s end, '%p') ] end @isomorphic = type.isomorphic? # continue to emit capability as false when rendering the ERB # template, so that pcore modules generated prior to puppet7 can be # read by puppet7 and vice-versa. @capability = false end |
Instance Attribute Details
#capability ⇒ Object (readonly)
Gets the capability member attribute of the type
30 31 32 |
# File 'lib/puppet/generate/models/type/type.rb', line 30 def capability @capability end |
#doc ⇒ Object (readonly)
Gets the doc string of the type.
15 16 17 |
# File 'lib/puppet/generate/models/type/type.rb', line 15 def doc @doc end |
#isomorphic ⇒ Object (readonly)
Gets the isomorphic member attribute of the type
27 28 29 |
# File 'lib/puppet/generate/models/type/type.rb', line 27 def isomorphic @isomorphic end |
#name ⇒ Object (readonly)
Gets the name of the type as a Puppet string literal.
12 13 14 |
# File 'lib/puppet/generate/models/type/type.rb', line 12 def name @name end |
#parameters ⇒ Object (readonly)
Gets the parameters of the type.
21 22 23 |
# File 'lib/puppet/generate/models/type/type.rb', line 21 def parameters @parameters end |
#properties ⇒ Object (readonly)
Gets the properties of the type.
18 19 20 |
# File 'lib/puppet/generate/models/type/type.rb', line 18 def properties @properties end |
#title_patterns ⇒ Object (readonly)
Gets the title patterns of the type
24 25 26 |
# File 'lib/puppet/generate/models/type/type.rb', line 24 def title_patterns @title_patterns end |
Instance Method Details
#render(template) ⇒ Object
61 62 63 |
# File 'lib/puppet/generate/models/type/type.rb', line 61 def render(template) template.result(binding) end |