Class: DataMapper::Property::EpochTime
- Inherits:
-
Integer
- Object
- Integer
- DataMapper::Property::EpochTime
- Defined in:
- lib/dm-types/epoch_time.rb
Instance Method Summary collapse
Instance Method Details
#dump(value) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/dm-types/epoch_time.rb', line 15 def dump(value) case value when ::Numeric, ::Time then value.to_i when ::DateTime then datetime_to_time(value).to_i end end |
#load(value) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dm-types/epoch_time.rb', line 7 def load(value) if value.kind_of?(::Numeric) ::Time.at(value.to_i) else value end end |