Class: ActiveRecord::Turntable::Algorithm::ModuloAlgorithm
- Defined in:
- lib/active_record/turntable/algorithm/modulo_algorithm.rb
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from ActiveRecord::Turntable::Algorithm::Base
Instance Method Details
#choose(shard_maps, key) ⇒ Object
4 5 6 7 8 |
# File 'lib/active_record/turntable/algorithm/modulo_algorithm.rb', line 4 def choose(shard_maps, key) shard_maps[key % shard_maps.size].shard rescue raise ActiveRecord::Turntable::CannotSpecifyShardError, "cannot specify shard for key:#{key.inspect}" end |