Class: Puppet::ResourceApi::TypeShim

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/resource_api/glue.rb

Overview

A trivial class to provide the functionality required to push data through the existing type/provider parts of puppet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, resource_hash, typename, namevarname, attr_def) ⇒ TypeShim

Returns a new instance of TypeShim.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/puppet/resource_api/glue.rb', line 7

def initialize(title, resource_hash, typename, namevarname, attr_def)
  # internalize and protect - needs to go deeper
  @values = resource_hash.dup
  # "name" is a privileged key
  @values[namevarname] = title
  @values.freeze

  @typename = typename
  @namevar = namevarname
  @attr_def = attr_def
end

Instance Attribute Details

#attr_defObject (readonly)

Returns the value of attribute attr_def.



5
6
7
# File 'lib/puppet/resource_api/glue.rb', line 5

def attr_def
  @attr_def
end

#namevarObject (readonly)

Returns the value of attribute namevar.



5
6
7
# File 'lib/puppet/resource_api/glue.rb', line 5

def namevar
  @namevar
end

#typenameObject (readonly)

Returns the value of attribute typename.



5
6
7
# File 'lib/puppet/resource_api/glue.rb', line 5

def typename
  @typename
end

#valuesObject (readonly)

Returns the value of attribute values.



5
6
7
# File 'lib/puppet/resource_api/glue.rb', line 5

def values
  @values
end

Instance Method Details

#nameObject



23
24
25
# File 'lib/puppet/resource_api/glue.rb', line 23

def name
  values[@namevar]
end

#to_resourceObject



19
20
21
# File 'lib/puppet/resource_api/glue.rb', line 19

def to_resource
  ResourceShim.new(@values, @typename, @namevar, @attr_def)
end