Sha256: 32f9997c2d688c5f48fb0393615ad91f089defd7aa8611eca4d4d16d729b9d6a

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

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

1 entries across 1 versions & 1 rubygems

Version Path
fresh_connection-3.0.0.rc1 lib/fresh_connection/rack/connection_management.rb