Class: EzPool::ConnectionManager
- Inherits:
-
Object
- Object
- EzPool::ConnectionManager
- Defined in:
- lib/ezpool/connection_manager.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #connect_with(&block) ⇒ Object
-
#create_new ⇒ Object
Create a new wrapped connection.
- #disconnect(conn) ⇒ Object
- #disconnect_with(&block) ⇒ Object
-
#initialize(connect_with, disconnect_with = nil) ⇒ ConnectionManager
constructor
A new instance of ConnectionManager.
Constructor Details
#initialize(connect_with, disconnect_with = nil) ⇒ ConnectionManager
Returns a new instance of ConnectionManager.
6 7 8 9 |
# File 'lib/ezpool/connection_manager.rb', line 6 def initialize(connect_with, disconnect_with = nil) @connect_with = connect_with @disconnect_with = disconnect_with end |
Instance Method Details
#connect ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ezpool/connection_manager.rb', line 11 def connect if @connect_with.nil? raise EzPool::ConnectCallableNeverConfigured.new() end @connect_with.call end |
#connect_with(&block) ⇒ Object
24 25 26 |
# File 'lib/ezpool/connection_manager.rb', line 24 def connect_with(&block) @connect_with = block end |
#create_new ⇒ Object
Create a new wrapped connection
34 35 36 |
# File 'lib/ezpool/connection_manager.rb', line 34 def create_new EzPool::ConnectionWrapper.new(connect, self) end |
#disconnect(conn) ⇒ Object
18 19 20 21 22 |
# File 'lib/ezpool/connection_manager.rb', line 18 def disconnect(conn) if !@disconnect_with.nil? @disconnect_with.call(conn) end end |
#disconnect_with(&block) ⇒ Object
28 29 30 |
# File 'lib/ezpool/connection_manager.rb', line 28 def disconnect_with(&block) @disconnect_with = block end |