Class: Familia::Connection::ParentDelegationHandler
- Inherits:
-
BaseConnectionHandler
- Object
- BaseConnectionHandler
- Familia::Connection::ParentDelegationHandler
- Defined in:
- lib/familia/connection/handlers.rb
Overview
Handler for delegating connection resolution to parent object
Used by DataType objects that are attached to a parent (Horreum instance or class). Delegates the connection resolution to the parent's dbclient method, which allows DataType objects to inherit connection settings, logical_database, and transaction context from their parent.
This preserves the existing architectural pattern where DataType objects owned by Horreum models use the parent's connection chain. This is the primary behavior for DataType objects in typical usage.
Instance Method Summary collapse
- #handle(uri) ⇒ Object
-
#initialize(data_type) ⇒ ParentDelegationHandler
constructor
A new instance of ParentDelegationHandler.
Constructor Details
#initialize(data_type) ⇒ ParentDelegationHandler
Returns a new instance of ParentDelegationHandler.
247 248 249 |
# File 'lib/familia/connection/handlers.rb', line 247 def initialize(data_type) @data_type = data_type end |
Instance Method Details
#handle(uri) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/familia/connection/handlers.rb', line 251 def handle(uri) return nil unless @data_type.parent # Delegate to parent's connection chain # Parent can be either a Horreum class or instance parent_connection = @data_type.parent.dbclient(uri) if parent_connection Familia.trace :DBCLIENT_PARENT_DELEGATION, @data_type.dbkey, "Using parent connection from #{@data_type.parent.class}" end parent_connection end |