Class: CouchRest::Server
- Inherits:
-
Object
- Object
- CouchRest::Server
- Defined in:
- lib/couchrest/core/server.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#uuid_batch_count ⇒ Object
Returns the value of attribute uuid_batch_count.
Instance Method Summary collapse
-
#create_db(name) ⇒ Object
create a database.
- #database(name) ⇒ Object
-
#database!(name) ⇒ Object
creates the database if it doesn’t exist.
-
#databases ⇒ Object
list all databases on the server.
-
#info ⇒ Object
get the welcome message.
-
#initialize(server = 'http://localhost:5984', uuid_batch_count = 1000) ⇒ Server
constructor
A new instance of Server.
- #next_uuid(count = @uuid_batch_count) ⇒ Object
-
#restart! ⇒ Object
restart the couchdb instance.
Constructor Details
#initialize(server = 'http://localhost:5984', uuid_batch_count = 1000) ⇒ Server
Returns a new instance of Server.
4 5 6 7 |
# File 'lib/couchrest/core/server.rb', line 4 def initialize server = 'http://localhost:5984', uuid_batch_count = 1000 @uri = server @uuid_batch_count = uuid_batch_count end |
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
3 4 5 |
# File 'lib/couchrest/core/server.rb', line 3 def uri @uri end |
#uuid_batch_count ⇒ Object
Returns the value of attribute uuid_batch_count.
3 4 5 |
# File 'lib/couchrest/core/server.rb', line 3 def uuid_batch_count @uuid_batch_count end |
Instance Method Details
#create_db(name) ⇒ Object
create a database
30 31 32 33 |
# File 'lib/couchrest/core/server.rb', line 30 def create_db name CouchRest.put "#{@uri}/#{name}" database name end |
#database(name) ⇒ Object
14 15 16 |
# File 'lib/couchrest/core/server.rb', line 14 def database name CouchRest::Database.new(self, name) end |
#database!(name) ⇒ Object
creates the database if it doesn’t exist
19 20 21 22 |
# File 'lib/couchrest/core/server.rb', line 19 def database! name create_db(name) rescue nil database name end |
#databases ⇒ Object
list all databases on the server
10 11 12 |
# File 'lib/couchrest/core/server.rb', line 10 def databases CouchRest.get "#{@uri}/_all_dbs" end |
#info ⇒ Object
get the welcome message
25 26 27 |
# File 'lib/couchrest/core/server.rb', line 25 def info CouchRest.get "#{@uri}/" end |