diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-17 16:29:43 -0700 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-17 16:29:43 -0700 |
commit | 76b34f57a4717fba6665656c4955b9f0abacdf74 (patch) | |
tree | eee5bb52ecc7c8a66eaa3dbd0f958db201b11215 /lib/puppet | |
parent | 3ccf483f77b026dde8a53bd8e9dff6a5fd0f6722 (diff) | |
parent | 19e049322879f5195b6fb653ae0c63e776e94835 (diff) | |
download | puppet-76b34f57a4717fba6665656c4955b9f0abacdf74.tar.gz puppet-76b34f57a4717fba6665656c4955b9f0abacdf74.tar.xz puppet-76b34f57a4717fba6665656c4955b9f0abacdf74.zip |
Merge branch 'indirection' of http://git.rickbradley.com/puppet into indirection
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/indirector.rb | 33 | ||||
-rw-r--r-- | lib/puppet/indirector/indirection.rb | 2 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 704039abc..13cf3991f 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -42,7 +42,7 @@ module Puppet::Indirector # Set up autoloading of the appropriate termini. instance_load name, "puppet/indirector/%s" % name end - + # Define a new indirection terminus. This method is used by the individual # termini in their separate files. Again, the autoloader takes care of # actually loading these files. @@ -77,14 +77,36 @@ module Puppet::Indirector if defined?(@indirection) raise ArgumentError, "Already performing an indirection of %s; cannot redirect %s" % [@indirection.name, indirection] end + + # JRB: this associates an indirection class with this class (e.g., Node.@indirection = Indirection.new(:node)) @indirection = Indirection.new(indirection, options) # Set up autoloading of the appropriate termini. Puppet::Indirector.register_indirection indirection - return @indirection + extend ClassMethods + include InstanceMethods end + module InstanceMethods + # these become instance methods + def save + end + end + + module ClassMethods + def find + end + + def destroy + end + + def search + end + end + + # JRB:FIXME: these methods to be deprecated: + # Define methods for each of the HTTP methods. These just point to the # termini, with consistent error-handling. Each method is called with # the first argument being the indirection type and the rest of the @@ -103,14 +125,13 @@ module Puppet::Indirector private - # Redirect a given HTTP method. + + # Redirect one of our methods to the corresponding method on the Terminus def redirect(method_name, *args) begin @indirection.terminus.send(method_name, *args) rescue NoMethodError => detail - if Puppet[:trace] - puts detail.backtrace - end + puts detail.backtrace if Puppet[:trace] raise ArgumentError, "The %s terminus of the %s indirection failed to respond to %s: %s" % [@indirection.terminus.name, @indirection.name, method_name, detail] end diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 7a4c4bd55..67b8a9d48 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -6,7 +6,7 @@ class Puppet::Indirector::Indirection def self.clear_cache @@indirections.each { |ind| ind.clear_cache } end - + attr_accessor :name, :termini attr_reader :to |