Class: WithConnection::ConnectionManagement

Inherits:
Object
  • Object
show all
Defined in:
lib/with_connection/connection_pool.rb

Constant Summary collapse

@@connection_pools =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ConnectionManagement

Returns a new instance of ConnectionManagement.



50
51
52
# File 'lib/with_connection/connection_pool.rb', line 50

def initialize(app)
  @app = app
end

Class Method Details

.connection_poolsObject



46
47
48
# File 'lib/with_connection/connection_pool.rb', line 46

def self.connection_pools
  @@connection_pools
end

Instance Method Details

#call(env) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/with_connection/connection_pool.rb', line 54

def call(env)
  @app.call(env)
ensure
  # Don't return connection (and perform implicit rollback) if
  # this request is a part of integration test
  unless env.key?("rack.test")
    self.class.connection_pools.each(&:release_connection_with_warning)
  end
end