Class: Salestation::Web::ActiveRecordConnectionManagement
- Inherits:
-
Object
- Object
- Salestation::Web::ActiveRecordConnectionManagement
- Defined in:
- lib/salestation/web/active_record_connection_management.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ActiveRecordConnectionManagement
constructor
A new instance of ActiveRecordConnectionManagement.
Constructor Details
#initialize(app) ⇒ ActiveRecordConnectionManagement
Returns a new instance of ActiveRecordConnectionManagement.
6 7 8 |
# File 'lib/salestation/web/active_record_connection_management.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/salestation/web/active_record_connection_management.rb', line 10 def call(env) testing = env['rack.test'] status, headers, body = @app.call(env) proxy = ::Rack::BodyProxy.new(body) do ActiveRecord::Base.clear_active_connections! unless testing end [status, headers, proxy] rescue Exception ActiveRecord::Base.clear_active_connections! unless testing raise end |