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.



59
60
61
# File 'lib/with_connection/connection_pool.rb', line 59

def initialize(app)
  @app = app
end

Class Method Details

.connection_poolsObject



55
56
57
# File 'lib/with_connection/connection_pool.rb', line 55

def self.connection_pools
  @@connection_pools
end

Instance Method Details

#call(env) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/with_connection/connection_pool.rb', line 63

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