Class: Attribeauty::Types::Time
- Inherits:
-
Object
- Object
- Attribeauty::Types::Time
- Defined in:
- lib/attribeauty/types/time.rb
Overview
custom Time type
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/attribeauty/types/time.rb', line 7 def cast(value) return if value.nil? case value when Time value when Date, DateTime value.to_time when Integer ::Time.at(value / 1000.0) when Numeric ::Time.at(value) else ::Time.parse(value) end end |