Method: ActiveRecord::Base.neverblock_postgresql_connection

Defined in:
lib/active_record/connection_adapters/neverblock_postgresql_adapter.rb

.neverblock_postgresql_connection(config) ⇒ Object

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/active_record/connection_adapters/neverblock_postgresql_adapter.rb', line 67

def self.neverblock_postgresql_connection(config) # :nodoc:
  config = config.symbolize_keys
  host     = config[:host]
  port     = config[:port] || 5432
  username = config[:username].to_s
  password = config[:password].to_s
  size     = config[:connections] || 4

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

  # The postgres drivers don't allow the creation of an unconnected PGconn object,
  # so just pass a nil connection object for the time being.
  ::ActiveRecord::ConnectionAdapters::NeverBlockPostgreSQLAdapter.new(nil, logger, [size, host, port, nil, nil, database, username, password], config)
end