Module: RedisModel::Types::Timestamp

Includes:
BaseValue
Defined in:
lib/redis_model/types/timestamp.rb

Overview

Internal: Methods needed for timestamp type.

Instance Method Summary collapse

Methods included from BaseValue

#get

Methods included from Base

#connection, #del, #exists?

Instance Method Details

#set(timestamp) ⇒ Object

Public: Sets ISO 8601 string of timestamp to Redis.

timestamp - Timestamp to store.

Returns nothing.



21
22
23
# File 'lib/redis_model/types/timestamp.rb', line 21

def set(timestamp)
  super(timestamp.utc.iso8601)
end

#to_timeObject Also known as: to_value

Public: Reads value on Redis and converts it to timestamp.

Returns Time object.



10
11
12
# File 'lib/redis_model/types/timestamp.rb', line 10

def to_time
  Time.parse(get) rescue nil
end