Sha256: 173cfb3ac41daddc1a7c4a3b5945b85dd9d88a36c407f80e0336e489cbaf7acb
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module RestAPI def put(uri, doc = nil) payload = doc.to_json if doc begin JSON.parse(RestClient.put(uri, payload)) rescue Exception => e if $DEBUG raise "Error while sending a PUT request #{uri}\npayload: #{payload.inspect}\n#{e}" else raise e end end end def get(uri) begin JSON.parse(RestClient.get(uri), :max_nesting => false) rescue => e if $DEBUG raise "Error while sending a GET request #{uri}\n: #{e}" else raise e end end end def post(uri, doc = nil) payload = doc.to_json if doc begin JSON.parse(RestClient.post(uri, payload)) rescue Exception => e if $DEBUG raise "Error while sending a POST request #{uri}\npayload: #{payload.inspect}\n#{e}" else raise e end end end def delete(uri) JSON.parse(RestClient.delete(uri)) end def copy(uri, destination) JSON.parse(RestClient::Request.execute( :method => :copy, :url => uri, :headers => {'Destination' => destination} ).to_s) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
couchrest-1.0.0.beta2 | lib/couchrest/rest_api.rb |
couchrest-1.0.0.beta | lib/couchrest/rest_api.rb |
samlown-couchrest-1.0.0 | lib/couchrest/rest_api.rb |