summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPieter van de Bruggen <pieter@puppetlabs.com>2011-03-18 20:53:00 -0700
committerPieter van de Bruggen <pieter@puppetlabs.com>2011-03-21 11:36:44 -0700
commitb187e071ac1b334878498d52ee6c18f8c0e6a5d9 (patch)
tree119e82d292fd730ee6c1126bea27ca77f7a332a6 /lib
parentf67e7fa39479751a7c5268bd32e503e35602ce4f (diff)
downloadpuppet-b187e071ac1b334878498d52ee6c18f8c0e6a5d9.tar.gz
puppet-b187e071ac1b334878498d52ee6c18f8c0e6a5d9.tar.xz
puppet-b187e071ac1b334878498d52ee6c18f8c0e6a5d9.zip
(#6786) Removing the #interface method.
Since constants are already being defined for each interface, the #interface method does little but provide another way to access the same data. Reviewed-By: Nick Lewis
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/interface.rb29
1 files changed, 9 insertions, 20 deletions
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 476de8bbf..f9b26950a 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -6,8 +6,10 @@ class Puppet::Interface
include Puppet::Interface::ActionManager
extend Puppet::Interface::ActionManager
+
# This is just so we can search for actions. We only use its
# list of directories to search.
+ # Can't we utilize an external autoloader, or simply use the $LOAD_PATH? -pvb
def self.autoloader
@autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/interface")
end
@@ -30,35 +32,22 @@ class Puppet::Interface
end
end
end
- @interfaces.keys
+ Puppet::Interface.constants.map { |c| c.to_s.downcase }
end
- # Return an interface by name, loading from disk if necessary.
- def self.interface(name)
- @interfaces ||= {}
- unless @interfaces[unify_name(name)]
- require "puppet/interface/#{unify_name(name)}"
- end
- @interfaces[unify_name(name)]
- rescue Exception => detail
- puts detail.backtrace if Puppet[:trace]
- $stderr.puts "Unable to find interface '#{name.to_s}': #{detail}."
+ def self.const_missing(name)
+ require "puppet/interface/#{name.to_s.downcase}"
+ const_get(name) if const_defined?(name)
+ rescue LoadError
+ nil
end
def self.register_interface(name, instance)
- @interfaces ||= {}
- @interfaces[unify_name(name)] = instance
const_set(name2const(name), instance)
end
def self.unload_interface(name)
- @interfaces ||= {}
- @interfaces.delete(unify_name(name))
- const = name2const(name)
- const_get(const)
- remove_const(const)
- rescue
- # nothing - if the constant-getting fails, just return
+ remove_const(name2const(name)) rescue nil
end
def self.unify_name(name)