Class: Puppet::ResourceApi::ResourceShim

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(resource_hash) ⇒ ResourceShim

Returns a new instance of ResourceShim.



28
29
30
# File 'lib/puppet/resource_api/glue.rb', line 28

def initialize(resource_hash)
  @values = resource_hash.dup.freeze # whatevs
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



26
27
28
# File 'lib/puppet/resource_api/glue.rb', line 26

def values
  @values
end

Instance Method Details

#prune_parameters(*_args) ⇒ Object



36
37
38
39
# File 'lib/puppet/resource_api/glue.rb', line 36

def prune_parameters(*_args)
  # puts "not pruning #{args.inspect}" if args.length > 0
  self
end

#titleObject



32
33
34
# File 'lib/puppet/resource_api/glue.rb', line 32

def title
  values[:name]
end

#to_manifestObject



41
42
43
44
# File 'lib/puppet/resource_api/glue.rb', line 41

def to_manifest
  # TODO: get the correct typename here
  (["SOMETYPE { #{values[:name].inspect}: "] + values.keys.reject { |k| k == :name }.map { |k| "  #{k} => #{values[k].inspect}," } + ['}']).join("\n")
end