Class: ConnectionPool::Wrapper
- Inherits:
-
BasicObject
- Defined in:
- lib/connection_pool/wrapper.rb
Constant Summary
collapse
- METHODS =
[:with, :pool_shutdown, :wrapped_pool]
Instance Method Summary
collapse
Constructor Details
#initialize(**options) ⇒ Wrapper
Returns a new instance of Wrapper.
5
6
7
|
# File 'lib/connection_pool/wrapper.rb', line 5
def initialize(**options, &)
@pool = options.fetch(:pool) { ::ConnectionPool.new(**options, &) }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
37
38
39
40
41
|
# File 'lib/connection_pool/wrapper.rb', line 37
def method_missing(name, *, **, &)
with do |connection|
connection.send(name, *, **, &)
end
end
|
Instance Method Details
#pool_available ⇒ Object
25
26
27
|
# File 'lib/connection_pool/wrapper.rb', line 25
def pool_available
@pool.available
end
|
#pool_shutdown ⇒ Object
17
18
19
|
# File 'lib/connection_pool/wrapper.rb', line 17
def pool_shutdown(&)
@pool.shutdown(&)
end
|
#pool_size ⇒ Object
21
22
23
|
# File 'lib/connection_pool/wrapper.rb', line 21
def pool_size
@pool.size
end
|
#respond_to?(id) ⇒ Boolean
29
30
31
|
# File 'lib/connection_pool/wrapper.rb', line 29
def respond_to?(id, *, **)
METHODS.include?(id) || with { |c| c.respond_to?(id, *, **) }
end
|
#respond_to_missing?(id) ⇒ Boolean
33
34
35
|
# File 'lib/connection_pool/wrapper.rb', line 33
def respond_to_missing?(id, *, **)
with { |c| c.respond_to?(id, *, **) }
end
|
#with ⇒ Object
13
14
15
|
# File 'lib/connection_pool/wrapper.rb', line 13
def with(**, &)
@pool.with(**, &)
end
|
#wrapped_pool ⇒ Object
9
10
11
|
# File 'lib/connection_pool/wrapper.rb', line 9
def wrapped_pool
@pool
end
|