Sha256: 21f245ceca29fe6a7d7faa11939e84a5b38274219e562a42c59dbf5a1bda1297

Contents?: true

Size: 550 Bytes

Versions: 4

Compression:

Stored size: 550 Bytes

Contents

module ActiveRecord::Turntable
  module ShardingCondition
    private

    def foreign_shard_key
      options[:foreign_shard_key] || foreign_target_model.turntable_shard_key
    end

    def foreign_target_model
      respond_to?(:model) ? model : owner
    end

    def should_use_shard_key?
      sharded_by_same_key? || !!options[:foreign_shard_key]
    end

    def sharded_by_same_key?
      foreign_target_model.turntable_enabled? &&
        klass.turntable_enabled? &&
        foreign_shard_key == klass.turntable_shard_key
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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