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.



66
67
68
# File 'lib/connection_pool.rb', line 66

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



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

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



70
71
72
73
74
# File 'lib/connection_pool.rb', line 70

def with
  yield @pool.checkout
ensure
  @pool.checkin
end