Sha256: c6ea578eec6ff94e21c37088981a7426de69194dfc95d81081cced00deeb43f2

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

module ActiveRecord::Turntable
  class SeqShard < Shard
    private

      def create_connection_class
        klass = get_or_set_connection_class
        klass.remove_connection
        klass.establish_connection ActiveRecord::Base.connection_pool.spec.config[:seq][name].with_indifferent_access
        klass
      end

      def retrieve_connection_pool
        ActiveRecord::Base.turntable_connections[name] ||=
          begin
            config = ActiveRecord::Base.configurations[Rails.env]["seq"][name]
            raise ArgumentError, "Unknown database config: #{name}, have #{ActiveRecord::Base.configurations.inspect}" unless config
            ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec_for(config))
          end
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-turntable-3.0.0.alpha3 lib/active_record/turntable/seq_shard.rb
activerecord-turntable-3.0.0.alpha2 lib/active_record/turntable/seq_shard.rb
activerecord-turntable-3.0.0.alpha1 lib/active_record/turntable/seq_shard.rb