Class: CouchDB::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/couchdb/client.rb,
lib/couchdb/client/version.rb

Constant Summary collapse

VERSION =
"1.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/couchdb/client.rb', line 7

def initialize(options = {})
  options = self.class.default_options.merge normalize_options(options)
  @connection = establish_connection options
end

Class Method Details

.default_optionsObject



3
4
5
# File 'lib/couchdb/client.rb', line 3

def self.default_options
  {:host => 'localhost', :port => 5984}
end

Instance Method Details

#all_dbsObject



12
13
14
# File 'lib/couchdb/client.rb', line 12

def all_dbs
  get '_all_dbs'
end

#db(name, doc_class = Document) ⇒ Object Also known as: []

Public: Get a Database with the given name.



17
18
19
# File 'lib/couchdb/client.rb', line 17

def db(name, doc_class = Document)
  DataBase.new self, name, doc_class
end

#delete(path, options = {}) ⇒ Object



35
36
37
# File 'lib/couchdb/client.rb', line 35

def delete(path, options = {})
  send_http_request :delete, path, options
end

#get(path, options = {}) ⇒ Object



23
24
25
# File 'lib/couchdb/client.rb', line 23

def get(path, options = {})
  send_http_request :get, path, options
end

#head(path, options = {}) ⇒ Object



39
40
41
# File 'lib/couchdb/client.rb', line 39

def head(path, options = {})
  send_http_request :head, path, options
end

#post(path, options = {}) ⇒ Object



31
32
33
# File 'lib/couchdb/client.rb', line 31

def post(path, options = {})
  send_http_request :post, path, {:headers => {'Content-Type' => 'application/json'}}.merge!(options)
end

#put(path, options = {}) ⇒ Object



27
28
29
# File 'lib/couchdb/client.rb', line 27

def put(path, options = {})
  send_http_request :put, path, {:headers => {'Content-Type' => 'application/json'}}.merge!(options)
end