Class: GOM::Storage::CouchDB::Adapter
- Inherits:
-
Adapter
- Object
- Adapter
- GOM::Storage::CouchDB::Adapter
- Defined in:
- lib/gom/storage/couchdb/adapter.rb
Overview
The couchdb storage adapter.
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #clear_revisions! ⇒ Object
- #collection(name, options = { }) ⇒ Object
- #count ⇒ Object
- #fetch(id) ⇒ Object
- #remove(id) ⇒ Object
- #revisions ⇒ Object
- #setup ⇒ Object
- #store(draft) ⇒ Object
- #teardown ⇒ Object
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
6 7 8 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 6 def database @database end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 5 def server @server end |
Instance Method Details
#clear_revisions! ⇒ Object
49 50 51 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 49 def clear_revisions! @revisions = nil end |
#collection(name, options = { }) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 38 def collection(name, = { }) view = @design.views[name.to_s] raise ViewNotFoundError, "there is no view with the name #{name}" unless view fetcher = GOM::Storage::CouchDB::Collection::Fetcher.new view, revisions, GOM::Object::Collection.new fetcher, configuration.name end |
#count ⇒ Object
34 35 36 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 34 def count GOM::Storage::CouchDB::Counter.new(@database).perform end |
#fetch(id) ⇒ Object
20 21 22 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 20 def fetch(id) GOM::Storage::CouchDB::Fetcher.new(@database, id, revisions).draft end |
#remove(id) ⇒ Object
30 31 32 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 30 def remove(id) GOM::Storage::CouchDB::Remover.new(@database, id, revisions).perform end |
#revisions ⇒ Object
45 46 47 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 45 def revisions @revisions ||= { } end |
#setup ⇒ Object
8 9 10 11 12 13 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 8 def setup initialize_server initialize_database setup_database push_design end |
#store(draft) ⇒ Object
24 25 26 27 28 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 24 def store(draft) saver = GOM::Storage::CouchDB::Saver.new @database, draft, revisions, configuration.name saver.perform saver.object_id end |
#teardown ⇒ Object
15 16 17 18 |
# File 'lib/gom/storage/couchdb/adapter.rb', line 15 def teardown clear_server clear_database end |