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

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

Overview

A model for Puppet resource types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ void

Initializes a type model.

Parameters:



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

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?
  @capability = type.is_capability?
end

Instance Attribute Details

#capabilityObject (readonly)

Gets the capability member attribute of the type



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

def capability
  @capability
end

#docObject (readonly)

Gets the doc string of the type.



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

def doc
  @doc
end

#isomorphicObject (readonly)

Gets the isomorphic member attribute of the type



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

def isomorphic
  @isomorphic
end

#nameObject (readonly)

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



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

def name
  @name
end

#parametersObject (readonly)

Gets the parameters of the type.



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

def parameters
  @parameters
end

#propertiesObject (readonly)

Gets the properties of the type.



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

def properties
  @properties
end

#title_patternsObject (readonly)

Gets the title patterns of the type



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

def title_patterns
  @title_patterns
end

Instance Method Details

#render(template) ⇒ Object



55
56
57
# File 'lib/puppet/generate/models/type/type.rb', line 55

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