Sha256: 2affbd3036915d4bd9271d4c2cc86f9cef8e403f3d35182c90981d30dd35be36
Contents?: true
Size: 860 Bytes
Versions: 6
Compression:
Stored size: 860 Bytes
Contents
require "active_support/core_ext/hash" class Kredis::Types::Hash < Kredis::Types::Proxying proxying :hget, :hset, :hmget, :hdel, :hgetall, :hkeys, :hvals, :del, :exists? attr_accessor :typed def [](key) string_to_type(hget(key), typed) end def []=(key, value) update key => value end def update(**entries) hset entries.transform_values{ |val| type_to_string(val, typed) } if entries.flatten.any? end def values_at(*keys) strings_to_types(hmget(keys) || [], typed) end def delete(*keys) hdel keys if keys.flatten.any? end def remove del end alias clear remove def entries (hgetall || {}).transform_values { |val| string_to_type(val, typed) }.with_indifferent_access end alias to_h entries def keys hkeys || [] end def values strings_to_types(hvals || [], typed) end end
Version data entries
6 entries across 6 versions & 1 rubygems