Module: SimpleRedisOrm::Helpers::CoreCommands::ClassMethods

Includes:
Serializer
Included in:
Entry
Defined in:
lib/simple-redis-orm/helpers/core_commands.rb

Instance Method Summary collapse

Methods included from Serializer

#deserialize_hash_value, #deserialize_value, #serialize_value

Instance Method Details

#read_by(key) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/simple-redis-orm/helpers/core_commands.rb', line 9

def read_by(key)
  type = redis.type key
  return if type.nil? || type == 'none'
  return read_hash(key) if type == 'hash'

  read_value(key)
end

#read_hash(key) ⇒ Object



17
18
19
20
# File 'lib/simple-redis-orm/helpers/core_commands.rb', line 17

def read_hash(key)
  value = redis.hgetall(key)
  deserialize_value(value)
end

#read_value(key) ⇒ Object



22
23
24
25
26
27
# File 'lib/simple-redis-orm/helpers/core_commands.rb', line 22

def read_value(key)
  value = redis.get(key)
  return if value.nil?

  deserialize_value(value)
end