Class: ActiveRecord::Turntable::MasterShard
- Defined in:
- lib/active_record/turntable/master_shard.rb
Constant Summary
Constants inherited from Shard
Instance Method Summary collapse
- #connection_pool ⇒ Object
-
#initialize(klass) ⇒ MasterShard
constructor
A new instance of MasterShard.
Methods inherited from Shard
Constructor Details
#initialize(klass) ⇒ MasterShard
Returns a new instance of MasterShard.
3 4 5 6 7 8 |
# File 'lib/active_record/turntable/master_shard.rb', line 3 def initialize(klass) (klass and klass.connection_pool) or raise MasterShardNotConnected, "connection_pool is nil" @klass = klass @name = 'master' end |
Instance Method Details
#connection_pool ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record/turntable/master_shard.rb', line 10 def connection_pool if ActiveRecord::Base == @klass ActiveRecord::Base.connection_pool else # use parentclass connection which is turntable disabled klass = @klass.superclass candidate_connection_pool = nil while !candidate_connection_pool if klass == ActiveRecord::Base or !klass.turntable_enabled? candidate_connection_pool = klass.connection_pool else klass = klass.superclass end end candidate_connection_pool end end |