summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 17:19:17 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 17:19:17 +0000
commit17306c01d4b608247cc76af0548a223119beac9a (patch)
tree3734c3594c67e8f8572508b8320434b5850786ba /lib
parent96f91f6856a60492e38427234acdf756f5825ab5 (diff)
downloadpuppet-17306c01d4b608247cc76af0548a223119beac9a.tar.gz
puppet-17306c01d4b608247cc76af0548a223119beac9a.tar.xz
puppet-17306c01d4b608247cc76af0548a223119beac9a.zip
Features now load dynamically using method_missing, so that undefined features never throw errors.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1987 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/feature.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/puppet/feature.rb b/lib/puppet/feature.rb
index 2d965ed47..ece8ec86a 100644
--- a/lib/puppet/feature.rb
+++ b/lib/puppet/feature.rb
@@ -2,6 +2,8 @@
# Copyright (c) 2006. All rights reserved.
class Puppet::Feature
+ attr_reader :path
+
# Create a new feature test. You have to pass the feature name,
# and it must be unique. You can either provide a block that
# will get executed immediately to determine if the feature
@@ -50,11 +52,24 @@ class Puppet::Feature
# Create a new feature collection.
def initialize(path)
@path = path
+ @loader = Puppet::Autoload.new(self, @path)
end
def load
- loader = Puppet::Autoload.new(self, @path)
- loader.loadall
+ @loader.loadall
+ end
+
+ def method_missing(method, *args)
+ return super unless method.to_s =~ /\?$/
+
+ feature = method.to_s.sub(/\?$/, '')
+ @loader.load(feature)
+
+ if respond_to?(method)
+ return self.send(method)
+ else
+ return false
+ end
end
end