Sha256: efe7a70cd94661a240b95e9ee2627561c8f86776571930b4ae976c5c506d0c99

Contents?: true

Size: 814 Bytes

Versions: 28

Compression:

Stored size: 814 Bytes

Contents

module ActiveRecord::Turntable
  class MasterShard < Shard
    def initialize(klass)
      (klass and klass.connection_pool) or
        raise MasterShardNotConnected, "connection_pool is nil"
      @klass = klass
      @name  = 'master'
    end

    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
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
activerecord-turntable-2.5.0 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.4.0 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.3.3 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.3.2 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.3.1 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.3.0 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.2.2 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.2.1 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.2.0 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.1 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.0 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.0.rc2 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.0.rc1 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.0.beta2 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.1.0.beta1 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.0.6 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.0.5 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.0.4 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.0.3 lib/active_record/turntable/master_shard.rb
activerecord-turntable-2.0.2 lib/active_record/turntable/master_shard.rb