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

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, options = {})
  connection(url, options) do |uri, conn|
    conn.copy(uri.request_uri, destination, options)
  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, options = {})
  connection(url, options) do |uri, conn|
    conn.delete(uri.request_uri, options)
  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, options = {})
  connection(url, options) do |uri, conn|
    conn.get(uri.request_uri, options)
  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, options = {})
  connection(url, options) do |uri, conn|
    conn.head(uri.request_uri, options)
  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, options = {})
  connection(url, options) do |uri, conn|
    conn.post(uri.request_uri, doc, options)
  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, options = {})
  connection(url, options) do |uri, conn|
    conn.put(uri.request_uri, doc, options)
  end
end