Module: Dynashard::ConnectionHandlerExtensions
- Defined in:
- lib/dynashard/connection_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#dynashard_pool_alias(model_class, shard_class) ⇒ Object
Set an connection pool entry for the model class pointing at the shard class’s pool.
-
#retrieve_connection_pool_with_dynashard(klass) ⇒ Object
Return a connection pool for the specified class.
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/dynashard/connection_handler.rb', line 3 def self.included(base) base.alias_method_chain :retrieve_connection_pool, :dynashard end |
Instance Method Details
#dynashard_pool_alias(model_class, shard_class) ⇒ Object
Set an connection pool entry for the model class pointing at the shard class’s pool. :nodoc: This is required for places that examine the connection pool to determine whether to use a given class’s connection or a parent class’s connection (eg. ActiveRecord::Base.arel_engine)
13 14 15 |
# File 'lib/dynashard/connection_handler.rb', line 13 def dynashard_pool_alias(model_class, shard_class) @connection_pools[model_class] = @connection_pools[shard_class] end |
#retrieve_connection_pool_with_dynashard(klass) ⇒ Object
Return a connection pool for the specified class. If the class is a Dynashard generated model subclass, return the connection for its shard class.
20 21 22 23 24 25 26 |
# File 'lib/dynashard/connection_handler.rb', line 20 def retrieve_connection_pool_with_dynashard(klass) if klass.respond_to?(:dynashard_klass) retrieve_connection_pool_without_dynashard(klass.dynashard_klass) else retrieve_connection_pool_without_dynashard(klass) end end |