Class: PGMQ::Transaction::TransactionalClient
- Inherits:
-
Object
- Object
- PGMQ::Transaction::TransactionalClient
- Defined in:
- lib/pgmq/transaction.rb
Overview
Minimal wrapper that ensures all operations use the transaction connection
Instance Method Summary collapse
-
#connection ⇒ Object
Expose parent’s connection (for tests/inspection).
-
#initialize(parent, conn) ⇒ TransactionalClient
constructor
A new instance of TransactionalClient.
-
#method_missing(method) ⇒ Object
Forward all method calls to parent, but use our transaction connection.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Check if method exists on parent.
-
#with_connection {|@conn| ... } ⇒ Object
Inject our transaction connection instead of using the pool.
Constructor Details
#initialize(parent, conn) ⇒ TransactionalClient
Returns a new instance of TransactionalClient.
54 55 56 57 58 59 60 |
# File 'lib/pgmq/transaction.rb', line 54 def initialize( parent, conn ) @parent = parent @conn = conn end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Forward all method calls to parent, but use our transaction connection
65 66 67 |
# File 'lib/pgmq/transaction.rb', line 65 def method_missing(method, ...) @parent.respond_to?(method, true) ? @parent.__send__(method, ...) : super end |
Instance Method Details
#connection ⇒ Object
Expose parent’s connection (for tests/inspection)
86 87 88 |
# File 'lib/pgmq/transaction.rb', line 86 def connection @parent.connection end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Check if method exists on parent
73 74 75 76 77 78 |
# File 'lib/pgmq/transaction.rb', line 73 def respond_to_missing?( method, include_private = false ) @parent.respond_to?(method, include_private) || super end |
#with_connection {|@conn| ... } ⇒ Object
Inject our transaction connection instead of using the pool
81 82 83 |
# File 'lib/pgmq/transaction.rb', line 81 def with_connection yield @conn end |