Class: GOM::Storage::CouchDB::Adapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/gom/storage/couchdb/adapter.rb

Overview

The couchdb storage adapter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



6
7
8
# File 'lib/gom/storage/couchdb/adapter.rb', line 6

def database
  @database
end

#serverObject (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

Raises:

  • (ViewNotFoundError)


38
39
40
41
42
43
# File 'lib/gom/storage/couchdb/adapter.rb', line 38

def collection(name, options = { })
  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, options
  GOM::Object::Collection.new fetcher, configuration.name
end

#countObject



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

#revisionsObject



45
46
47
# File 'lib/gom/storage/couchdb/adapter.rb', line 45

def revisions
  @revisions ||= { }
end

#setupObject



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

#teardownObject



15
16
17
18
# File 'lib/gom/storage/couchdb/adapter.rb', line 15

def teardown
  clear_server
  clear_database
end