This is primarily for Hiera/DataLibrary support,
but is a decent idea regardless.

Signed-off-by: Luke Kanies <[email protected]>
---
Local-branch: refactor/master/8232-array_indexers_on_scope
 lib/puppet/parser/scope.rb     |    4 ++++
 spec/unit/parser/scope_spec.rb |    9 +++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index 711655e..7b75ca8 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -87,6 +87,10 @@ class Puppet::Parser::Scope
     @compiler.node.name
   end
 
+  def include?(name)
+    self[name] != :undefined
+  end
+
   # Is the value true?  This allows us to control the definition of truth
   # in one place.
   def self.true?(value)
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index e081800..887890e 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -113,6 +113,15 @@ describe Puppet::Parser::Scope do
       @scope["var"].should == "childval"
     end
 
+    it "should be able to detect when variables are set" do
+      @scope["var"] = "childval"
+      @scope.should be_include("var")
+    end
+
+    it "should be able to detect when variables are not set" do
+      @scope.should_not be_include("var")
+    end
+
     describe "and the variable is qualified" do
       before do
         @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foonode"))
-- 
1.7.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to