Class: ActiveRecord::Turntable::Rack::ConnectionManagement

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/turntable/rack/connection_management.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ConnectionManagement

Returns a new instance of ConnectionManagement.



4
5
6
# File 'lib/active_record/turntable/rack/connection_management.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/active_record/turntable/rack/connection_management.rb', line 8

def call(env)
  @app.call(env)
ensure
  unless env.key?("rack.test")
    ActiveRecord::Base.connection_handler.clear_all_connections!
    ActiveRecord::Base.clear_all_connections!
  end
end