Module: RestAPI
- Defined in:
- lib/aqua/store/couch_db/http_client/rest_api.rb
Overview
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
Class Method Summary collapse
Instance Method Summary collapse
- #copy(uri, destination) ⇒ Object
- #delete(uri) ⇒ Object
- #get(uri, streamable = false) ⇒ Object
- #post(uri, doc = nil) ⇒ Object
- #put(uri, doc = nil) ⇒ Object
Class Method Details
.adapter ⇒ Object
23 24 25 |
# File 'lib/aqua/store/couch_db/http_client/rest_api.rb', line 23 def self.adapter @adapter end |
.adapter=(klass) ⇒ Object
19 20 21 |
# File 'lib/aqua/store/couch_db/http_client/rest_api.rb', line 19 def self.adapter=( klass ) @adapter = klass end |
Instance Method Details
#copy(uri, destination) ⇒ Object
57 58 59 60 |
# File 'lib/aqua/store/couch_db/http_client/rest_api.rb', line 57 def copy(uri, destination) response = RestAPI.adapter.copy(uri, {'Destination' => destination}) JSON.parse( response ) end |
#delete(uri) ⇒ Object
52 53 54 55 |
# File 'lib/aqua/store/couch_db/http_client/rest_api.rb', line 52 def delete(uri) response = RestAPI.adapter.delete(uri) JSON.parse( response ) end |
#get(uri, streamable = false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aqua/store/couch_db/http_client/rest_api.rb', line 33 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 |