Class: Puppet::DSL::ResourceTypeAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/puppet/dsl/resource_type_api.rb

Overview

Type of the objects inside of which pure ruby manifest files are executed. Provides methods for creating defines, hostclasses, and nodes.

Instance Method Summary collapse

Constructor Details

#initializeResourceTypeAPI

Returns a new instance of ResourceTypeAPI.



7
8
9
# File 'lib/vendor/puppet/dsl/resource_type_api.rb', line 7

def initialize
  @__created_ast_objects__ = []
end

Instance Method Details

#define(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vendor/puppet/dsl/resource_type_api.rb', line 11

def define(name, *args, &block)
  args = args.inject([]) do |result, item|
    if item.is_a?(Hash)
      item.each { |p, v| result << [p, v] }
    else
      result << item
    end
    result
  end
  @__created_ast_objects__.push Puppet::Parser::AST::Definition.new(name, {:arguments => args}, &block)
  nil
end

#hostclass(name, options = {}, &block) ⇒ Object



24
25
26
27
# File 'lib/vendor/puppet/dsl/resource_type_api.rb', line 24

def hostclass(name, options = {}, &block)
  @__created_ast_objects__.push Puppet::Parser::AST::Hostclass.new(name, options, &block)
  nil
end

#node(name, options = {}, &block) ⇒ Object



29
30
31
32
33
# File 'lib/vendor/puppet/dsl/resource_type_api.rb', line 29

def node(name, options = {}, &block)
  name = [name] unless name.is_a?(Array)
  @__created_ast_objects__.push Puppet::Parser::AST::Node.new(name, options, &block)
  nil
end