Sha256: 6e2ed5279d2641d5b52ff1201e541537718658201f20e74286cd4ab2942c872f

Contents?: true

Size: 515 Bytes

Versions: 11

Compression:

Stored size: 515 Bytes

Contents

module FreshConnection
  module Rack
    class ConnectionManagement
      def initialize(app)
        @app = app
      end

      def call(env)
        testing = env['rack.test']

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fresh_connection-2.4.4 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.3 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.2 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.0 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.0.rc4 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.0.rc3 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.4.0.rc1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.3.2 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.3.1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.3.0 lib/fresh_connection/rack/connection_management.rb