Class: ActiveRecord::Base

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

Class Method Summary collapse

Class Method Details

.sqlserver_connection(config) ⇒ Object

:nodoc:


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 26

def self.sqlserver_connection(config) #:nodoc:
  config = config.symbolize_keys
  config.reverse_merge! :mode => :dblib
  mode = config[:mode].to_s.downcase.underscore.to_sym
  case mode
  when :dblib
    require 'tiny_tds'
  when :odbc
    raise ArgumentError, 'Missing :dsn configuration.' unless config.has_key?(:dsn)
    require 'odbc'
    require 'active_record/connection_adapters/sqlserver/core_ext/odbc'
  else
    raise ArgumentError, "Unknown connection mode in #{config.inspect}."
  end
  ConnectionAdapters::SQLServerAdapter.new(nil, logger, nil, config.merge(:mode=>mode))
end