Class: Rooq::ConnectionProvider
- Inherits:
-
Object
- Object
- Rooq::ConnectionProvider
- Defined in:
- lib/rooq/connection.rb
Overview
Abstract interface for connection lifecycle management. Implementations control how connections are acquired and released.
This is inspired by jOOQ's ConnectionProvider interface.
Direct Known Subclasses
Instance Method Summary collapse
-
#acquire ⇒ Object
Acquire a connection for query execution.
-
#release(connection) ⇒ Object
Release a previously acquired connection.
-
#with_connection {|connection| ... } ⇒ Object
Execute a block with an acquired connection, ensuring release.
Instance Method Details
#acquire ⇒ Object
Acquire a connection for query execution.
13 14 15 |
# File 'lib/rooq/connection.rb', line 13 def acquire raise NotImplementedError, "#{self.class} must implement #acquire" end |
#release(connection) ⇒ Object
Release a previously acquired connection.
20 21 22 |
# File 'lib/rooq/connection.rb', line 20 def release(connection) raise NotImplementedError, "#{self.class} must implement #release" end |
#with_connection {|connection| ... } ⇒ Object
Execute a block with an acquired connection, ensuring release.
27 28 29 30 31 32 33 34 |
# File 'lib/rooq/connection.rb', line 27 def with_connection connection = acquire begin yield connection ensure release(connection) end end |