Module: CouchRest::Model::Connection::ClassMethods
- Defined in:
- lib/couchrest/model/connection.rb
Instance Method Summary (collapse)
-
- (Object) database
Overwrite the default database method so that it always provides something from the configuration.
- - (Object) prepare_database(db = nil)
- - (Object) server
-
- (Object) use_database(db)
Overwrite the normal use_database method so that a database name can be provided instead of a full connection.
Instance Method Details
- (Object) database
Overwrite the default database method so that it always provides something from the configuration
20 21 22 |
# File 'lib/couchrest/model/connection.rb', line 20 def database super || (@database ||= prepare_database) end |
- (Object) prepare_database(db = nil)
28 29 30 31 32 33 34 35 36 |
# File 'lib/couchrest/model/connection.rb', line 28 def prepare_database(db = nil) unless db.is_a?(CouchRest::Database) conf = connection_configuration db = [conf[:prefix], db.to_s, conf[:suffix]].reject{|s| s.to_s.empty?}.join(conf[:join]) self.server.database!(db) else db end end |
- (Object) server
24 25 26 |
# File 'lib/couchrest/model/connection.rb', line 24 def server @server ||= CouchRest::Server.new(prepare_server_uri) end |
- (Object) use_database(db)
Overwrite the normal use_database method so that a database name can be provided instead of a full connection.
14 15 16 |
# File 'lib/couchrest/model/connection.rb', line 14 def use_database(db) @database = prepare_database(db) end |