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 included from Enumerable

#uniq

Methods inherited from Puppet::Parser::AST

#inspect, #safeevaluate

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

#initialize(argshash) ⇒ ResourceParam

Returns a new instance of ResourceParam.



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

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.



4
5
6
# File 'lib/puppet/parser/ast/resourceparam.rb', line 4

def add
  @add
end

#paramObject

Returns the value of attribute param.



4
5
6
# File 'lib/puppet/parser/ast/resourceparam.rb', line 4

def param
  @param
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/puppet/parser/ast/resourceparam.rb', line 4

def value
  @value
end

Instance Method Details

#eachObject



11
12
13
# File 'lib/puppet/parser/ast/resourceparam.rb', line 11

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

#evaluate(scope) ⇒ Object

Return the parameter and the value.



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

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

#to_sObject



28
29
30
# File 'lib/puppet/parser/ast/resourceparam.rb', line 28

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