Class: Puppet::Parser::AST::ResourceParam

Inherits:
Branch show all
Defined in:
lib/puppet/parser/ast/resourceparam.rb

Overview

The AST object for the parameters inside resource expressions

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Instance Attribute Summary collapse

Attributes inherited from Branch

#children, #pin

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #pos, #scope

Instance Method Summary collapse

Methods inherited from Puppet::Parser::AST

#inspect, #safeevaluate

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Constructor Details

#initialize(argshash) ⇒ ResourceParam

Returns a new instance of ResourceParam.



8
9
10
11
# File 'lib/puppet/parser/ast/resourceparam.rb', line 8

def initialize(argshash)
  Puppet.warn_once('deprecations', 'AST::ResourceParam', _('Use of Puppet::Parser::AST::ResourceParam is deprecated and not fully functional'))
  super(argshash)
end

Instance Attribute Details

#addObject

Returns the value of attribute add.



6
7
8
# File 'lib/puppet/parser/ast/resourceparam.rb', line 6

def add
  @add
end

#paramObject

Returns the value of attribute param.



6
7
8
# File 'lib/puppet/parser/ast/resourceparam.rb', line 6

def param
  @param
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/puppet/parser/ast/resourceparam.rb', line 6

def value
  @value
end

Instance Method Details

#eachObject



13
14
15
# File 'lib/puppet/parser/ast/resourceparam.rb', line 13

def each
  [@param, @value].each { |child| yield child }
end

#evaluate(scope) ⇒ Object

Return the parameter and the value.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet/parser/ast/resourceparam.rb', line 18

def evaluate(scope)
  value = @value.safeevaluate(scope)
  Puppet::Parser::Resource::Param.new(
    :name => @param,
    :value => value.nil? ? :undef : value,
    :source => scope.source,
    :line => line,
    :file => file,
    :add => add
  )
end

#to_sObject



30
31
32
# File 'lib/puppet/parser/ast/resourceparam.rb', line 30

def to_s
  "#{@param} => #{@value}"
end