summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-07-19 14:57:23 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-19 19:56:06 -0700
commit539d71635132bd5f772a550b7bfff530e8b59b68 (patch)
tree1f1ae2297bf9b13f62473f918f3ae4d172326fa9 /lib/puppet
parentd2da1d45aaf44de7fd0648b3bab48887838549d8 (diff)
downloadpuppet-539d71635132bd5f772a550b7bfff530e8b59b68.tar.gz
puppet-539d71635132bd5f772a550b7bfff530e8b59b68.tar.xz
puppet-539d71635132bd5f772a550b7bfff530e8b59b68.zip
[#4287] Fix the undefined evaluate_match error when comparing functions
Ticket #4238 introduced a problem that a function couldn't compare to another value until after it was evaluated, and AST::Function didn't have the evaluate_match method. This change moves that method from AST::Leaf to AST. The special casing necessary for doing comparisons between AST objects feels messy and could probably be encapsulated better. I've created ticket #4291 to remind us to refactor this at some point. Paired with: Nick Lewis Signed-off-by: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast.rb14
-rw-r--r--lib/puppet/parser/ast/leaf.rb14
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index 2773a240e..54e034acb 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -87,6 +87,20 @@ class Puppet::Parser::AST
def initialize(args)
set_options(args)
end
+
+ # evaluate ourselves, and match
+ def evaluate_match(value, scope)
+ obj = self.safeevaluate(scope)
+
+ obj = obj.downcase if obj.respond_to?(:downcase)
+ value = value.downcase if value.respond_to?(:downcase)
+
+ obj = Puppet::Parser::Scope.number?(obj) || obj
+ value = Puppet::Parser::Scope.number?(value) || value
+
+ # "" == undef for case/selector/if
+ obj == value or (obj == "" and value == :undef)
+ end
end
# And include all of the AST subclasses.
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 49f430278..db9788f50 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -10,20 +10,6 @@ class Puppet::Parser::AST
@value
end
- # evaluate ourselves, and match
- def evaluate_match(value, scope)
- obj = self.safeevaluate(scope)
-
- obj = obj.downcase if obj.respond_to?(:downcase)
- value = value.downcase if value.respond_to?(:downcase)
-
- obj = Puppet::Parser::Scope.number?(obj) || obj
- value = Puppet::Parser::Scope.number?(value) || value
-
- # "" == undef for case/selector/if
- obj == value or (obj == "" and value == :undef)
- end
-
def match(value)
@value == value
end