Class: Couch::Database
- Defined in:
- lib/couch/database.rb
Defined Under Namespace
Constant Summary
Constants included from Log
Instance Method Summary collapse
- #delete(url) ⇒ Object
-
#get(url) ⇒ Object
– forward HTTP methods to server object.
-
#initialize(host, port, db, recreate = false) ⇒ Database
constructor
A new instance of Database.
- #memoized_views ⇒ Object
- #post(url, data) ⇒ Object
- #put(url, data) ⇒ Object
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_views ⇒ Object
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 |