From baa412c6ed30d19ee43bf37b3bba60bf372fac5a Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 26 Apr 2006 16:02:41 +0000 Subject: Adding "defined" functino to puppet, so you can now test whether a given class or definition is defined. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1135 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/parser/functions.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index bc7e870ae..61070627f 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -97,6 +97,20 @@ module Functions return true end end + + # Test whether a given class or definition is defined + newfunction(:defined, :rvalue) do |vals| + retval = true + + vals.each do |val| + unless builtintype?(val) or lookuptype(val) + retval = false + break + end + end + + return retval + end end end -- cgit