Module: CouchRest::RestAPI
- Included in:
- CouchRest
- Defined in:
- lib/couchrest/rest_api.rb
Overview
CouchRest RestAPI
Backwards compatible wrapper for instantiating a connection and performing a request on demand. Useful for quick requests, but not recommended for general usage due the extra overhead of establishing a connection.
Instance Method Summary collapse
-
#copy(url, destination, options = {}) ⇒ Object
Send a COPY request to the URI provided.
-
#delete(url, options = {}) ⇒ Object
Send a DELETE request.
-
#get(url, options = {}) ⇒ Object
Send a GET request.
-
#head(url, options = {}) ⇒ Object
Send a HEAD request.
-
#post(url, doc = nil, options = {}) ⇒ Object
Send a POST request.
-
#put(url, doc = nil, options = {}) ⇒ Object
Send a PUT request.
Instance Method Details
#copy(url, destination, options = {}) ⇒ Object
Send a COPY request to the URI provided.
42 43 44 45 46 |
# File 'lib/couchrest/rest_api.rb', line 42 def copy(url, destination, = {}) connection(url, ) do |uri, conn| conn.copy(uri.request_uri, destination, ) end end |
#delete(url, options = {}) ⇒ Object
Send a DELETE request.
35 36 37 38 39 |
# File 'lib/couchrest/rest_api.rb', line 35 def delete(url, = {}) connection(url, ) do |uri, conn| conn.delete(uri.request_uri, ) end end |
#get(url, options = {}) ⇒ Object
Send a GET request.
14 15 16 17 18 |
# File 'lib/couchrest/rest_api.rb', line 14 def get(url, = {}) connection(url, ) do |uri, conn| conn.get(uri.request_uri, ) end end |
#head(url, options = {}) ⇒ Object
Send a HEAD request.
49 50 51 52 53 |
# File 'lib/couchrest/rest_api.rb', line 49 def head(url, = {}) connection(url, ) do |uri, conn| conn.head(uri.request_uri, ) end end |
#post(url, doc = nil, options = {}) ⇒ Object
Send a POST request.
28 29 30 31 32 |
# File 'lib/couchrest/rest_api.rb', line 28 def post(url, doc = nil, = {}) connection(url, ) do |uri, conn| conn.post(uri.request_uri, doc, ) end end |
#put(url, doc = nil, options = {}) ⇒ Object
Send a PUT request.
21 22 23 24 25 |
# File 'lib/couchrest/rest_api.rb', line 21 def put(url, doc = nil, = {}) connection(url, ) do |uri, conn| conn.put(uri.request_uri, doc, ) end end |