Module: ActiveRecord::ConnectionHandling

Defined in:
lib/active_record/connection_adapters/firebird/connection.rb

Instance Method Summary collapse

Instance Method Details

#firebird_connection(config) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_record/connection_adapters/firebird/connection.rb', line 2

def firebird_connection(config)
  require 'active_record/extensions'
  require 'active_record/internal_metadata_extensions'

  config = config.symbolize_keys.dup.reverse_merge(downcase_names: true, port: 3050, encoding: ActiveRecord::ConnectionAdapters::FirebirdAdapter::DEFAULT_ENCODING)

  if config[:host]
    config[:database] = "#{config[:host]}/#{config[:port]}:#{config[:database]}"
  else
    config[:database] = File.expand_path(config[:database], Rails.root)
  end

  connection = ::Fb::Database.new(config).connect

  ActiveRecord::ConnectionAdapters::FirebirdAdapter.new(connection, logger, config)
end