Method: Conflow::Redis::HashField#to_h

Defined in:
lib/conflow/redis/hash_field.rb

#to_hString Also known as: to_hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates Ruby Hash based on soted values. Keys will be symbolized and values JSON-parsed

Examples:

field.to_h #=> { smart: true, degree: "none" }

Returns:

  • (String)

    Redis response



40
41
42
43
44
# File 'lib/conflow/redis/hash_field.rb', line 40

def to_h
  command(:hgetall, [key]).each_with_object({}) do |(key, value), hash|
    hash[key.to_sym] = JSON.parse(value)
  end
end