Class: ConnectionPool::Wrapper
- Inherits:
-
Object
- Object
- ConnectionPool::Wrapper
- Defined in:
- lib/connection_pool.rb
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #method_missing(name, *args, &block) ⇒ Object
- #with ⇒ Object (also: #with_connection)
Constructor Details
#initialize(options = {}, &block) ⇒ Wrapper
Returns a new instance of Wrapper.
79 80 81 |
# File 'lib/connection_pool.rb', line 79 def initialize( = {}, &block) @pool = ::ConnectionPool.new(, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
90 91 92 93 94 |
# File 'lib/connection_pool.rb', line 90 def method_missing(name, *args, &block) @pool.with do |connection| connection.send(name, *args, &block) end end |
Instance Method Details
#with ⇒ Object Also known as: with_connection
83 84 85 86 87 |
# File 'lib/connection_pool.rb', line 83 def with yield @pool.checkout ensure @pool.checkin end |