Class: ActiveRecord::ConnectionAdapters::RefreshConnectionManagement
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::RefreshConnectionManagement
- Defined in:
- lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RefreshConnectionManagement
constructor
A new instance of RefreshConnectionManagement.
Constructor Details
#initialize(app) ⇒ RefreshConnectionManagement
Returns a new instance of RefreshConnectionManagement.
4 5 6 |
# File 'lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_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 16 17 18 19 20 21 |
# File 'lib/activerecord-refresh_connection/active_record/connection_adapters/refresh_connection_management.rb', line 8 def call(env) testing = env.key?('rack.test') response = @app.call(env) response[2] = ::Rack::BodyProxy.new(response[2]) do # disconnect all connections on the connection pool ActiveRecord::Base.clear_all_connections! unless testing end response rescue Exception ActiveRecord::Base.clear_all_connections! unless testing raise end |