Sha256: 23ca0583d1e74d50f4700b2c49814530e0b75c88a6a4d2cd8f3728b150f0fbc7
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 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) response = RestAPI.adapter.get(uri) JSON.parse( response , :max_nesting => false) 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
4 entries across 4 versions & 1 rubygems