Module: ActiveRecordShards::DefaultSlavePatches::ActiveRelationPatches

Defined in:
lib/active_record_shards/default_slave_patches.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/active_record_shards/default_slave_patches.rb', line 97

def self.included(base)
  [:calculate, :exists?, :pluck, :find_with_associations].each do |m|
    ActiveRecordShards::DefaultSlavePatches.wrap_method_in_on_slave(false, base, m)
  end

  # ActiveRecord::Explain in v3 will eagerly establish an on_master
  # connection just to just the _static_ `supports_explain?` method on
  # the Mysql2Adapter
  if ActiveRecord::VERSION::MAJOR == 3
    ActiveRecordShards::DefaultSlavePatches.wrap_method_in_on_slave(false, base, :logging_query_plan)
  end
end

Instance Method Details

#on_slave_unless_txObject



110
111
112
# File 'lib/active_record_shards/default_slave_patches.rb', line 110

def on_slave_unless_tx
  @klass.on_slave_unless_tx { yield }
end