Module: ActiveRecord::Turntable::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/turntable/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#shards_transaction(options = {}, &block) ⇒ Object



111
112
113
# File 'lib/active_record/turntable/base.rb', line 111

def shards_transaction(options = {}, &block)
  self.class.shards_transaction(options, &block)
end

#turntable_shardActiveRecord::Turntable::Shard

Returns current shard for self.

Returns:



116
117
118
# File 'lib/active_record/turntable/base.rb', line 116

def turntable_shard
  turntable_cluster.shard_for(self.send(turntable_shard_key))
end

#with_shard(shard) ⇒ Object



121
122
123
# File 'lib/active_record/turntable/base.rb', line 121

def with_shard(shard)
  self.class.connection.with_shard(shard) { yield }
end