Class: Ensql::PoolWrapper
- Inherits:
-
Object
- Object
- Ensql::PoolWrapper
- Defined in:
- lib/ensql/pool_wrapper.rb
Overview
Wrap a 3rd-party connection pool with a standard interface. Connections can be checked out by #with
Instance Method Summary collapse
-
#initialize(&connection_block) ⇒ PoolWrapper
constructor
Wraps a block for accessing a connection from a pool.
-
#with {|connection| ... } ⇒ Object
Get a connection from our source pool.
Constructor Details
#initialize(&connection_block) ⇒ PoolWrapper
Wraps a block for accessing a connection from a pool.
PoolWrapper.new do |client_block|
my_connection_pool.with_connection(&client_block)
end
11 12 13 |
# File 'lib/ensql/pool_wrapper.rb', line 11 def initialize(&connection_block) @connection_block = connection_block end |
Instance Method Details
#with {|connection| ... } ⇒ Object
Get a connection from our source pool
17 18 19 |
# File 'lib/ensql/pool_wrapper.rb', line 17 def with(&client_block) @connection_block.call(client_block) end |