Sha256: 35a32c517adab216247d9ceb4e402950709ea3c7331fca53df51082a39239b7b
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
require "active_record/associations" module ActiveRecord::Turntable module ActiveRecordExt module Association include ShardingCondition def self.prepended(mod) ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :foreign_shard_key end protected # @note Override to pass shard key conditions def target_scope return super unless should_use_shard_key? scope = klass.where( klass.turntable_shard_key => owner.send(foreign_shard_key) ) super.merge!(scope) end private def skip_statement_cache? super || should_use_shard_key? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-turntable-3.0.0.alpha3 | lib/active_record/turntable/active_record_ext/association.rb |