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.
55 56 57 58 59 60 61 |
# File 'lib/pgmq/transaction.rb', line 55 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
66 67 68 |
# File 'lib/pgmq/transaction.rb', line 66 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)
87 88 89 |
# File 'lib/pgmq/transaction.rb', line 87 def connection @parent.connection end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
Check if method exists on parent
74 75 76 77 78 79 |
# File 'lib/pgmq/transaction.rb', line 74 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
82 83 84 |
# File 'lib/pgmq/transaction.rb', line 82 def with_connection yield @conn end |