Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/ingres_adapter.rb

Class Method Summary collapse

Class Method Details

.ingres_connection(config) ⇒ Object

Establishes a connection to the database that’s used by all Active Record objects



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record/connection_adapters/ingres_adapter.rb', line 9

def self.ingres_connection(config) # :nodoc:
  require 'Ingres' unless self.class.const_defined?(:Ingres)

  config = config.symbolize_keys
  host = config[:host]
  port = config[:port] || 21064
  username = config[:username].to_s if config[:username]
  password = config[:password].to_s if config[:password]

  if config.key?(:database)
    database = config[:database]
  else
    raise ArgumentError, "No database specified. Missing argument: database."
  end

  #return the connection adapter
  ConnectionAdapters::IngresAdapter.new(nil, logger, [host, port, nil, nil, database, username, password], config)
end