Class: ConnectionPool::Wrapper
- Inherits:
-
BasicObject
- Defined in:
- lib/connection_pool.rb
Constant Summary
collapse
- METHODS =
[:with, :pool_shutdown]
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}, &block) ⇒ Wrapper
Returns a new instance of Wrapper.
91
92
93
|
# File 'lib/connection_pool.rb', line 91
def initialize(options = {}, &block)
@pool = ::ConnectionPool.new(options, &block)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
109
110
111
112
113
|
# File 'lib/connection_pool.rb', line 109
def method_missing(name, *args, &block)
@pool.with do |connection|
connection.send(name, *args, &block)
end
end
|
Instance Method Details
#pool_shutdown(&block) ⇒ Object
101
102
103
|
# File 'lib/connection_pool.rb', line 101
def pool_shutdown(&block)
@pool.shutdown(&block)
end
|
#respond_to?(id, *args) ⇒ Boolean
105
106
107
|
# File 'lib/connection_pool.rb', line 105
def respond_to?(id, *args)
METHODS.include?(id) || @pool.with { |c| c.respond_to?(id, *args) }
end
|
#with ⇒ Object
95
96
97
98
99
|
# File 'lib/connection_pool.rb', line 95
def with
yield @pool.checkout
ensure
@pool.checkin
end
|