polished documentation
This commit is contained in:
parent
26c4db7fc6
commit
b3b58ffa83
6 changed files with 20 additions and 11 deletions
|
@ -5,6 +5,12 @@ module CouchRest
|
|||
class Database
|
||||
attr_reader :server, :host, :name, :root
|
||||
|
||||
# Create a CouchRest::Database adapter for the supplied CouchRest::Server and database name.
|
||||
#
|
||||
# ==== Parameters
|
||||
# server<CouchRest::Server>:: database host
|
||||
# name<String>:: database name
|
||||
#
|
||||
def initialize server, name
|
||||
@name = name
|
||||
@server = server
|
||||
|
@ -12,6 +18,7 @@ module CouchRest
|
|||
@root = "#{host}/#{name}"
|
||||
end
|
||||
|
||||
# returns the database's uri
|
||||
def to_s
|
||||
@root
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ module CouchRest
|
|||
end
|
||||
end # module InstanceMethods
|
||||
|
||||
# these show up as class methods on models that include CouchRest::Model
|
||||
# Class methods for models that include CouchRest::Model
|
||||
module ClassMethods
|
||||
# override the CouchRest::Model-wide default_database
|
||||
def use_database db
|
||||
|
|
|
@ -6,37 +6,39 @@ module CouchRest
|
|||
@uuid_batch_count = uuid_batch_count
|
||||
end
|
||||
|
||||
# list all databases on the server
|
||||
# List all databases on the server
|
||||
def databases
|
||||
CouchRest.get "#{@uri}/_all_dbs"
|
||||
end
|
||||
|
||||
# Returns a CouchRest::Database for the given name
|
||||
def database name
|
||||
CouchRest::Database.new(self, name)
|
||||
end
|
||||
|
||||
# creates the database if it doesn't exist
|
||||
# Creates the database if it doesn't exist
|
||||
def database! name
|
||||
create_db(name) rescue nil
|
||||
database name
|
||||
end
|
||||
|
||||
# get the welcome message
|
||||
# GET the welcome message
|
||||
def info
|
||||
CouchRest.get "#{@uri}/"
|
||||
end
|
||||
|
||||
# create a database
|
||||
# Create a database
|
||||
def create_db name
|
||||
CouchRest.put "#{@uri}/#{name}"
|
||||
database name
|
||||
end
|
||||
|
||||
# restart the couchdb instance
|
||||
# Restart the CouchDB instance
|
||||
def restart!
|
||||
CouchRest.post "#{@uri}/_restart"
|
||||
end
|
||||
|
||||
# Retrive an unused UUID from CouchDB. Server instances manage caching a list of unused UUIDs.
|
||||
def next_uuid count = @uuid_batch_count
|
||||
@uuids ||= []
|
||||
if @uuids.empty?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue