Sha256: b15f40a0dfe668eaf4ef8d580ebe8f554bdc7725f4b6fdea1b948adffa51bd6a
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# HTTP Adapters should implement the following to be used with the RestAPI module # # def self.get(uri, headers=nil) # end # # def self.post(uri, hash, headers=nil) # end # # def self.put(uri, hash, headers=nil) # end # # def self.delete(uri, headers=nil) # end # # def self.copy(uri, headers) # end module RestAPI def self.adapter=( klass ) @adapter = klass end def self.adapter @adapter end def put(uri, doc = nil) hash = doc.to_json if doc response = RestAPI.adapter.put( uri, hash ) JSON.parse( response ) end def get(uri, streamable=false) response = RestAPI.adapter.get(uri) begin JSON.parse( response , :max_nesting => false) rescue Exception => e if streamable response else raise e end end end def post(uri, doc = nil) hash = doc.to_json if doc response = RestAPI.adapter.post(uri, hash) JSON.parse( response ) end def delete(uri) response = RestAPI.adapter.delete(uri) JSON.parse( response ) end def copy(uri, destination) response = RestAPI.adapter.copy(uri, {'Destination' => destination}) JSON.parse( response ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aqua-0.2.0 | lib/aqua/store/couch_db/http_client/rest_api.rb |
aqua-0.1.6 | lib/aqua/store/couch_db/http_client/rest_api.rb |