Sha256: 8eedd3f4e89828c2bd729fc7e2ac1e3f64617d1d35f992cbf230943a09212984

Contents?: true

Size: 532 Bytes

Versions: 44

Compression:

Stored size: 532 Bytes

Contents

module DbCharmer
  module Sharding
    module Method
      class HashMap
        attr_accessor :map

        def initialize(config)
          @map = config[:map].clone or raise ArgumentError, "No :map defined!"
        end

        def shard_for_key(key)
          res = map[key] || map[:default]
          raise ArgumentError, "Invalid key value, no shards found for this key!" unless res
          return res
        end

        def support_default_shard?
          map.has_key?(:default)
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
db-charmer-1.7.0.pre4 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre3 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre2 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre1 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.19 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.18 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.17 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.16 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.15 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.14 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.13 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.12 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.11 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.10 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.9 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.8 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.7 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.6 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.5 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.6.4 lib/db_charmer/sharding/method/hash_map.rb