Method: CouchPillow::MultiDBDirective#db

Defined in:
lib/couchpillow/directives/multi_db.rb

#db(conn) ⇒ Object

Set a DB connection. Overrides the default CouchPillow.db connection for the first time this method gets called. Subsequent calls will set secondary connections, which will only be used for write only.

Example:

db primary_db # use for both read and write
db backup_db1 # write only
db backup_db2 # write only


14
15
16
17
18
19
20
21
22
# File 'lib/couchpillow/directives/multi_db.rb', line 14

def db conn
  # set the primary db connection
  @primary_db ||= conn

  # insert as backup db connections
  if conn && @primary_db && conn != @primary_db
    _secondary_dbs << conn
  end
end