Class: CouchClient::Database
- Inherits:
-
Object
- Object
- CouchClient::Database
- Defined in:
- lib/couch-client/database.rb
Overview
Database is just an organized collection of functions that interact with the CouchDB database such as stats, creation, compaction, replication and deletion.
Instance Method Summary collapse
- #compact! ⇒ Object
- #create ⇒ Object
- #delete! ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(connection) ⇒ Database
constructor
Database is constructed with a connection that is used to make HTTP requests to the server.
- #inspect ⇒ Object
-
#replicate ⇒ Object
TODO: add replicate method.
- #stats ⇒ Object
Constructor Details
#initialize(connection) ⇒ Database
Database is constructed with a connection that is used to make HTTP requests to the server.
6 7 8 |
# File 'lib/couch-client/database.rb', line 6 def initialize(connection) @connection = connection end |
Instance Method Details
#compact! ⇒ Object
26 27 28 |
# File 'lib/couch-client/database.rb', line 26 def compact! @connection.hookup.post(["_compact"]).last end |
#create ⇒ Object
18 19 20 |
# File 'lib/couch-client/database.rb', line 18 def create @connection.hookup.put.last end |
#delete! ⇒ Object
22 23 24 |
# File 'lib/couch-client/database.rb', line 22 def delete! @connection.hookup.delete.last end |
#exists? ⇒ Boolean
14 15 16 |
# File 'lib/couch-client/database.rb', line 14 def exists? @connection.hookup.get.first == 200 end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/couch-client/database.rb', line 35 def inspect "#<#{self.class}>" end |
#replicate ⇒ Object
TODO: add replicate method
31 32 33 |
# File 'lib/couch-client/database.rb', line 31 def replicate raise "pending" end |
#stats ⇒ Object
10 11 12 |
# File 'lib/couch-client/database.rb', line 10 def stats @connection.hookup.get.last end |