Class: DbBrowser::ConnectionMan

Inherits:
Object
  • Object
show all
Defined in:
lib/dbbrowser/connection.rb

Overview

connection manager

Defined Under Namespace

Classes: AbstractModel, Column, Connection, Result, Table

Constant Summary collapse

CONNECTS =

get connection names

def connection_names
  ActiveRecord::Base.configurations.keys
end
{}

Instance Method Summary collapse

Instance Method Details

#connection_for(key) ⇒ Object

cache connections



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dbbrowser/connection.rb', line 12

def connection_for( key )
  # cache connections - needed? why? why not??
  con = CONNECTS[ key ] ||= AbstractModel.connection_for( key )

  # note: make sure connection is active?
  #  use verify!  - will try active? followed by reconnect!
  # - todo: check ourselves if active? - why? why not??
  con.verify!

  # wrap ActiveRecord connection in our own connection class
  Connection.new( con, key )
end