Class: ConnectionPool::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/connection_pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Wrapper

Returns a new instance of Wrapper.



79
80
81
# File 'lib/connection_pool.rb', line 79

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



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

#withObject 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