Class: Couch::Database

Inherits:
Object show all
Includes:
Base, Bulk, Log
Defined in:
lib/couch/database.rb

Defined Under Namespace

Modules: Base, Bulk

Constant Summary

Constants included from Log

Log::QUIET

Instance Method Summary collapse

Methods included from Bulk

#async, #create, #destroy, #do_bulked, #flush, included, #read, #update

Methods included from Base

#create, #destroy, #read, #update

Constructor Details

#initialize(host, port, db, recreate = false) ⇒ Database

Returns a new instance of Database.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/couch/database.rb', line 10

def initialize(host, port, db, recreate = false)
  @server = Couch::Server.new host, port
  @db = db

  if recreate
    Couch::Error.ignore { @server.delete("/#{db}") }
    @server.put("/#{db}/", "")
  else
    Couch::Error.ignore { @server.put("/#{db}/", "") }
  end
end

Instance Method Details

#delete(url) ⇒ Object



36
37
38
# File 'lib/couch/database.rb', line 36

def delete(url)
  @server.delete("/#{@db}/#{url}")
end

#get(url) ⇒ Object

– forward HTTP methods to server object.



24
25
26
# File 'lib/couch/database.rb', line 24

def get(url)
  @server.get("/#{@db}/#{url}")
end

#memoized_viewsObject



6
7
8
# File 'lib/couch/database.rb', line 6

def memoized_views
  @memoized_views ||= {}
end

#post(url, data) ⇒ Object



28
29
30
# File 'lib/couch/database.rb', line 28

def post(url, data)
  @server.post("/#{@db}/#{url}", data)
end

#put(url, data) ⇒ Object



32
33
34
# File 'lib/couch/database.rb', line 32

def put(url, data)
  @server.put("/#{@db}/#{url}", data)
end