Class: DataMapper::Adapters::CouchDBAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- DataMapper::Adapters::CouchDBAdapter
- Defined in:
- lib/couchdb_adapter/adapter.rb
Constant Summary collapse
- ConnectionError =
Class.new(StandardError)
Instance Method Summary collapse
-
#create(resources) ⇒ Integer
Persists one or many new resources.
-
#db_name ⇒ Object
Returns the name of the CouchDB database.
-
#delete(collection) ⇒ Integer
Deletes one or many existing resources.
-
#escaped_db_name ⇒ Object
Returns the name of the CouchDB database after being escaped.
-
#read(query) ⇒ Enumerable<Hash>
Reads one or many resources from a datastore.
-
#update(attributes, collection) ⇒ Integer
Updates one or many existing resources.
Instance Method Details
#create(resources) ⇒ Integer
Persists one or many new resources
Adapters provide specific implementation of this method
20 21 22 |
# File 'lib/couchdb_adapter/adapter.rb', line 20 def create(resources) raise NotImplementedError, "#{self.class}#create not implemented" end |
#db_name ⇒ Object
Returns the name of the CouchDB database.
85 86 87 88 89 90 91 92 |
# File 'lib/couchdb_adapter/adapter.rb', line 85 def db_name result = [:path].scan(/^\/?([-_+%()$a-z0-9]+?)\/?$/).flatten[0] if result != nil return Addressable::URI.unencode_component(result) else raise StandardError, "Invalid database path: '#{[:path]}'" end end |
#delete(collection) ⇒ Integer
Deletes one or many existing resources
Adapters provide specific implementation of this method
78 79 80 |
# File 'lib/couchdb_adapter/adapter.rb', line 78 def delete(collection) raise NotImplementedError, "#{self.class}#delete not implemented" end |
#escaped_db_name ⇒ Object
Returns the name of the CouchDB database after being escaped.
95 96 97 98 |
# File 'lib/couchdb_adapter/adapter.rb', line 95 def escaped_db_name return Addressable::URI.encode_component( self.db_name, Addressable::URI::CharacterClasses::UNRESERVED) end |
#read(query) ⇒ Enumerable<Hash>
Reads one or many resources from a datastore
Adapters provide specific implementation of this method
38 39 40 41 42 |
# File 'lib/couchdb_adapter/adapter.rb', line 38 def read(query) with_connection do |connection| end end |
#update(attributes, collection) ⇒ Integer
Updates one or many existing resources
Adapters provide specific implementation of this method
60 61 62 |
# File 'lib/couchdb_adapter/adapter.rb', line 60 def update(attributes, collection) raise NotImplementedError, "#{self.class}#update not implemented" end |