summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/scope.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/scope.rb')
-rw-r--r--lib/puppet/parser/scope.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index a6e43e7b3..32b127a6b 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -183,6 +183,25 @@ class Puppet::Parser::Scope
end
end
+ # Return a hash containing our variables and their values, optionally (and
+ # by default) including the values defined in our parent. Local values
+ # shadow parent values.
+ def to_hash(recursive = true)
+ if recursive and parent then
+ target = parent.to_hash(recursive)
+ end
+ target ||= Hash.new
+ @symtable.keys.each { |name|
+ value = @symtable[name]
+ if value == :undef then
+ target.delete(name)
+ else
+ target[name] = value
+ end
+ }
+ return target
+ end
+
def namespaces
@namespaces.dup
end