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.9.1 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.9.0 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.4 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.3 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.2 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.1 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.0 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.8.0.pre1 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.14 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.13 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.10 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.9 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.8 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.4.0 lib/db_charmer/sharding/method/hash_map.rb
yam-db-charmer-1.7.01 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.1 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre7 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre6 lib/db_charmer/sharding/method/hash_map.rb
db-charmer-1.7.0.pre5 lib/db_charmer/sharding/method/hash_map.rb