Class: ActiveRecord::ConnectionAdapters::ConnectionManagement

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ConnectionManagement

Returns a new instance of ConnectionManagement.



614
615
616
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 614

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 618

def call(env)
  testing = env.key?('rack.test')

  response = @app.call(env)
  response[2] = ::Rack::BodyProxy.new(response[2]) do
    ActiveRecord::Base.clear_active_connections! unless testing
  end

  response
rescue Exception
  ActiveRecord::Base.clear_active_connections! unless testing
  raise
end