Class: Familia::Connection::ParentDelegationHandler
- Inherits:
-
Object
- Object
- Familia::Connection::ParentDelegationHandler
- Includes:
- Handler
- 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.
369 370 371 |
# File 'lib/familia/connection/handlers.rb', line 369 def initialize(data_type) @data_type = data_type end |
Instance Method Details
#handle(uri) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/familia/connection/handlers.rb', line 373 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 |