module ActiveRecordShards::DefaultReplicaPatches::ActiveRelationPatches

Public Class Methods

included(base) click to toggle source
# File lib/active_record_shards/default_replica_patches.rb, line 131
def self.included(base)
  [:calculate, :exists?, :pluck, :load].each do |m|
    ActiveRecordShards::DefaultReplicaPatches.wrap_method_in_on_replica(false, base, m)
  end

  if ActiveRecord::VERSION::MAJOR == 4
    # `where` and `having` clauses call `create_binds`, which will use the primary connection
    ActiveRecordShards::DefaultReplicaPatches.wrap_method_in_on_replica(false, base, :create_binds, force_on_replica: true)
  end

  ActiveRecordShards::DefaultReplicaPatches.wrap_method_in_on_replica(false, base, :to_sql, force_on_replica: true)
end

Public Instance Methods

on_replica_unless_tx() { || ... } click to toggle source
# File lib/active_record_shards/default_replica_patches.rb, line 144
def on_replica_unless_tx
  @klass.on_replica_unless_tx { yield }
end