Class: PhobosDBCheckpoint::Middleware::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/phobos_db_checkpoint/middleware/database.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Database

Returns a new instance of Database.



5
6
7
8
9
# File 'lib/phobos_db_checkpoint/middleware/database.rb', line 5

def initialize(app, options = {})
  @app = app
  pool_size = options.fetch(:pool_size, PhobosDBCheckpoint::DEFAULT_POOL_SIZE)
  PhobosDBCheckpoint.configure(pool_size: pool_size)
end

Instance Method Details

#call(request_env) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/phobos_db_checkpoint/middleware/database.rb', line 11

def call(request_env)
  ActiveRecord::Base.connection_pool.with_connection do
    @app.call(request_env)
  end
ensure
  ActiveRecord::Base.clear_active_connections!
end