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
-
#set(timestamp) ⇒ Object
Public: Sets ISO 8601 string of timestamp to Redis.
-
#to_time ⇒ Object
(also: #to_value)
Public: Reads value on Redis and converts it to timestamp.
Methods included from BaseValue
Methods included from Base
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() super(.utc.iso8601) end |
#to_time ⇒ Object 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 |