Class: RunTimeSettings::Type::Time
- Inherits:
-
Object
- Object
- RunTimeSettings::Type::Time
- Defined in:
- lib/run_time_settings/type/time.rb
Overview
Time
Custom type caster for Time. Values are converted to an integer representing seconds since epoch for storage in the database, then converted back to Time on the way out.
This is only accurate to the second; milliseconds are lost.
Instance Method Summary collapse
-
#deserialize(value) ⇒ Object
called by read, should return Time instance.
-
#serialize(value) ⇒ Object
called by write, should convert to unix epoch for storage in database.
Instance Method Details
#deserialize(value) ⇒ Object
called by read, should return Time instance
13 14 15 |
# File 'lib/run_time_settings/type/time.rb', line 13 def deserialize(value) ::Time.at(value.to_i) end |
#serialize(value) ⇒ Object
called by write, should convert to unix epoch for storage in database
18 19 20 |
# File 'lib/run_time_settings/type/time.rb', line 18 def serialize(value) value.to_i end |