Class: SQLRunner::Adapters::ActiveRecord::ConnectionPool

Inherits:
Object
  • Object
show all
Defined in:
lib/sql_runner/adapters/active_record.rb

Instance Method Summary collapse

Instance Method Details

#shutdownObject



48
49
# File 'lib/sql_runner/adapters/active_record.rb', line 48

def shutdown
end

#withObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/sql_runner/adapters/active_record.rb', line 31

def with
  ::ActiveRecord::Base.connection_pool.with_connection do |connection|
    connection = connection.instance_variable_get(:@connection)

    adapter = case connection.class.name
              when "PG::Connection"
                PostgreSQL.new(connection)
              when "Mysql2::Client"
                MySQL.new(connection)
              else
                raise UnsupportedDatabase
              end

    yield(adapter)
  end
end