Class: PhobosDBCheckpoint::Middleware::Database
- Inherits:
-
Object
- Object
- PhobosDBCheckpoint::Middleware::Database
- Defined in:
- lib/phobos_db_checkpoint/middleware/database.rb
Instance Method Summary collapse
- #call(request_env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Database
constructor
A new instance of Database.
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, = {}) @app = app pool_size = .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 |