Class: Familia::Connection::CachedConnectionHandler
- Inherits:
-
BaseConnectionHandler
- Object
- BaseConnectionHandler
- Familia::Connection::CachedConnectionHandler
- Defined in:
- lib/familia/connection/handlers.rb
Overview
Checks for a dbclient class instance variable with a cached client instance
This works on any module, class, or instance that implements has a dbclient method. From a Horreum model instance, if you call CachedConnectionHandler.new(self) it'll return self.dbclient or nil, or you can call CachedConnectionHandler(self.class) and it'll attempt the same using the model's class.
+familia_module+ is required.
CachedConnectionHandler - Single cached connection - block all multi-mode operations
Instance Method Summary collapse
- #handle(_uri) ⇒ Object
-
#initialize(familia_module) ⇒ CachedConnectionHandler
constructor
A new instance of CachedConnectionHandler.
Constructor Details
#initialize(familia_module) ⇒ CachedConnectionHandler
Returns a new instance of CachedConnectionHandler.
212 213 214 |
# File 'lib/familia/connection/handlers.rb', line 212 def initialize(familia_module) @familia_module = familia_module end |
Instance Method Details
#handle(_uri) ⇒ Object
216 217 218 219 220 221 222 |
# File 'lib/familia/connection/handlers.rb', line 216 def handle(_uri) dbclient = @familia_module.instance_variable_get(:@dbclient) return nil unless dbclient Familia.trace :DBCLIENT_INSTVAL_OVERRIDE, nil, "Using @dbclient from #{@familia_module.class}" dbclient end |