summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2008-04-02 01:15:53 -0500
committerLuke Kanies <luke@madstop.com>2008-04-11 13:10:39 -0500
commit1befd1d8f1d389f425a36b1515dbba7408ac6238 (patch)
tree04b54514b83497692e492cded04b1cc10d5ae836 /lib
parentf28f20b675737741a98b1b87b4791f736a996d40 (diff)
downloadpuppet-1befd1d8f1d389f425a36b1515dbba7408ac6238.tar.gz
puppet-1befd1d8f1d389f425a36b1515dbba7408ac6238.tar.xz
puppet-1befd1d8f1d389f425a36b1515dbba7408ac6238.zip
work-in-progress; playing with refactoring network_* methods inside Indirector::REST
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/rest.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb
index 076e96356..33ae34006 100644
--- a/lib/puppet/indirector/rest.rb
+++ b/lib/puppet/indirector/rest.rb
@@ -4,11 +4,20 @@ require 'uri'
# Access objects via REST
class Puppet::Indirector::REST < Puppet::Indirector::Terminus
def network_fetch(path)
- Net::HTTP.get(URI.parse("http://127.0.0.1:34343/#{path}"))
+ network(path, 'get')
end
def network_delete(path)
- Net::HTTP.start("127.0.0.1", 34343) {|x| x.delete("/#{path}").body } # weird-ass net/http library
+ network(path, 'delete')
+ end
+
+ def network_put(path, data)
+ network(path, 'put', data)
+ end
+
+ def network(path, meth, data = nil)
+ # TODO: include data here, for #save
+ Net::HTTP.start("127.0.0.1", 34343) {|x| x.send(meth.to_sym, "/#{path}").body } # weird-ass net/http library
end
def find(name, options = {})