summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/resourceparam.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/ast/resourceparam.rb')
-rw-r--r--lib/puppet/parser/ast/resourceparam.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/puppet/parser/ast/resourceparam.rb b/lib/puppet/parser/ast/resourceparam.rb
new file mode 100644
index 000000000..248e91b32
--- /dev/null
+++ b/lib/puppet/parser/ast/resourceparam.rb
@@ -0,0 +1,42 @@
+require 'puppet/parser/ast/branch'
+
+class Puppet::Parser::AST
+ # The AST object for the parameters inside ResourceDefs and Selectors.
+ class ResourceParam < AST::Branch
+ attr_accessor :value, :param
+
+ def each
+ [@param,@value].each { |child| yield child }
+ end
+
+ # Return the parameter and the value.
+ def evaluate(hash)
+ scope = hash[:scope]
+ param = @param
+ value = @value.safeevaluate(:scope => scope)
+
+ args = {:name => param, :value => value, :source => scope.source}
+ [:line, :file].each do |p|
+ if v = self.send(p)
+ args[p] = v
+ end
+ end
+
+ return Puppet::Parser::Resource::Param.new(args)
+ end
+
+ def tree(indent = 0)
+ return [
+ @param.tree(indent + 1),
+ ((@@indline * indent) + self.typewrap(self.pin)),
+ @value.tree(indent + 1)
+ ].join("\n")
+ end
+
+ def to_s
+ return "%s => %s" % [@param,@value]
+ end
+ end
+end
+
+# $Id$