Sha256: 17d010202e50440f283492f344134f3c693abf99a97d36dd849a79816bdf4546
Contents?: true
Size: 829 Bytes
Versions: 2
Compression:
Stored size: 829 Bytes
Contents
require "active_support/core_ext/hash" class Kredis::Types::Hash < Kredis::Types::Proxying proxying :hget, :hset, :hmget, :hdel, :hgetall, :hkeys, :hvals, :del 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kredis-0.4.0 | lib/kredis/types/hash.rb |
kredis-0.3.1 | lib/kredis/types/hash.rb |