Class: Puppet::Generate::Models::Type::Type Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/generate/models/type/type.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A model for Puppet resource types.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a type model.

Parameters:

  • The Puppet type to model.

API:

  • private



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/puppet/generate/models/type/type.rb', line 34

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 = Hash[type.title_patterns.map 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

#capabilityObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the capability member attribute of the type

API:

  • private



29
30
31
# File 'lib/puppet/generate/models/type/type.rb', line 29

def capability
  @capability
end

#docObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the doc string of the type.

API:

  • private



14
15
16
# File 'lib/puppet/generate/models/type/type.rb', line 14

def doc
  @doc
end

#isomorphicObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the isomorphic member attribute of the type

API:

  • private



26
27
28
# File 'lib/puppet/generate/models/type/type.rb', line 26

def isomorphic
  @isomorphic
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

API:

  • private



11
12
13
# File 'lib/puppet/generate/models/type/type.rb', line 11

def name
  @name
end

#parametersObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the parameters of the type.

API:

  • private



20
21
22
# File 'lib/puppet/generate/models/type/type.rb', line 20

def parameters
  @parameters
end

#propertiesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the properties of the type.

API:

  • private



17
18
19
# File 'lib/puppet/generate/models/type/type.rb', line 17

def properties
  @properties
end

#title_patternsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Gets the title patterns of the type

API:

  • private



23
24
25
# File 'lib/puppet/generate/models/type/type.rb', line 23

def title_patterns
  @title_patterns
end

Instance Method Details

#render(template) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



59
60
61
# File 'lib/puppet/generate/models/type/type.rb', line 59

def render(template)
  template.result(binding)
end