Class: Lore::Connection_Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/lore/adapters/context.rb

Constant Summary collapse

@@pool =
Hash.new

Class Method Summary collapse

Class Method Details

.get_connection(db_name) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/lore/adapters/context.rb', line 45

def self.get_connection(db_name)
  
  db_name = db_name.to_sym
  
  # If requested connection is not in pool yet: 
  if !@@pool.has_key? db_name then
  # Try to establish connection
    connection = Lore::Connection.establish(db_name)
    connection.exec(Lore.on_connect_commands)
    @@pool[db_name] = connection
  end

  # Return requested connection
  return @@pool[db_name]

end