Sha256: 2f9c70e5d4c2c4234759d1c80a66bc463cf2bd7a31c6342c287e5ee88fa3b645

Contents?: true

Size: 511 Bytes

Versions: 15

Compression:

Stored size: 511 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.slave_connection_put_aside! unless testing
        end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fresh_connection-2.2.0 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.1.2 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.1.1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.1.0 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.0.4 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.0.3 lib/fresh_connection/rack/connection_management.rb
fresh_connection-0.4.4 lib/fresh_connection/rack/connection_management.rb
fresh_connection-1.0.1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.0.2 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.0.1 lib/fresh_connection/rack/connection_management.rb
fresh_connection-2.0.0 lib/fresh_connection/rack/connection_management.rb
fresh_connection-1.0.0 lib/fresh_connection/rack/connection_management.rb
fresh_connection-0.4.3 lib/fresh_connection/rack/connection_management.rb
fresh_connection-0.4.2 lib/fresh_connection/rack/connection_management.rb
fresh_connection-0.4.1 lib/fresh_connection/rack/connection_management.rb