summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface.rb
diff options
context:
space:
mode:
authorDan Bode <bodepd@gmail.com>2011-02-13 02:55:42 -0600
committerLuke Kanies <luke@puppetlabs.com>2011-02-20 15:17:27 -0800
commita54ee1e292238145bb0def2af6cf9ac22f2acd68 (patch)
treea578d867d2d7381bec94ba3fd3a8ea62a6619d1e /lib/puppet/interface.rb
parent7e3a02339a660a76019bf20243a7068325f1af68 (diff)
downloadpuppet-a54ee1e292238145bb0def2af6cf9ac22f2acd68.tar.gz
puppet-a54ee1e292238145bb0def2af6cf9ac22f2acd68.tar.xz
puppet-a54ee1e292238145bb0def2af6cf9ac22f2acd68.zip
(#2) Should not assume interfaces have indirectors
The initial work assumed that all interfaces were just skins on an indirected data type, but some interfaces will be more abstract than that. This commit removes that assumption by extracting all of the indirector work into a new Indirector subclass of Interface and then makes all of the new interfaces a subclass of that rather than of Interface itself.
Diffstat (limited to 'lib/puppet/interface.rb')
-rw-r--r--lib/puppet/interface.rb67
1 files changed, 1 insertions, 66 deletions
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 08a26db90..999c38bad 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -38,21 +38,6 @@ class Puppet::Interface
end).sort { |a,b| a.to_s <=> b.to_s }
end
- # Here's your opportunity to override the indirection name. By default
- # it will be the same name as the interface.
- def self.indirection_name
- name.to_sym
- end
-
- # Return an indirection associated with an interface, if one exists
- # One usually does.
- def self.indirection
- unless @indirection
- raise "Could not find data type '#{indirection_name}' for interface '#{name}'" unless @indirection = Puppet::Indirector::Indirection.instance(indirection_name)
- end
- @indirection
- end
-
# Return an interface by name, loading from disk if necessary.
def self.interface(name)
require "puppet/interface/#{name.to_s.downcase}"
@@ -83,7 +68,7 @@ class Puppet::Interface
@name || self.to_s.sub(/.+::/, '').downcase
end
- attr_accessor :from, :type, :verb, :name, :arguments, :indirection
+ attr_accessor :type, :verb, :name, :arguments
def action?(name)
self.class.actions.include?(name.to_sym)
@@ -98,26 +83,6 @@ class Puppet::Interface
end
end
- action :destroy do |name, *args|
- call_indirection_method(:destroy, name, *args)
- end
-
- action :find do |name, *args|
- call_indirection_method(:find, name, *args)
- end
-
- action :save do |name, *args|
- call_indirection_method(:save, name, *args)
- end
-
- action :search do |name, *args|
- call_indirection_method(:search, name, *args)
- end
-
- def indirection
- self.class.indirection
- end
-
def initialize(options = {})
options.each { |opt, val| send(opt.to_s + "=", val) }
@@ -126,34 +91,4 @@ class Puppet::Interface
self.class.load_actions
end
- def set_terminus(from)
- begin
- indirection.terminus_class = from
- rescue => detail
- raise "Could not set '#{indirection.name}' terminus to '#{from}' (#{detail}); valid terminus types are #{terminus_classes(indirection.name).join(", ") }"
- end
- end
-
- def call_indirection_method(method, name, *args)
- begin
- result = indirection.send(method, name, *args)
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- raise "Could not call #{method} on #{type}: #{detail}"
- end
-
- unless result
- raise "Could not #{method} #{indirection.name} for #{name}"
- end
-
- result
- end
-
- def indirections
- Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
- end
-
- def terminus_classes(indirection)
- Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort
- end
end