Class: Parameters::Types::Time
- Defined in:
- lib/parameters/types/time.rb
Class Method Summary collapse
-
.coerce(value) ⇒ ::Time
Coerces a value into a Time object.
Methods inherited from Object
Methods inherited from Type
#<, #<=, #==, ===, #===, #coerce, #to_ruby, to_ruby
Class Method Details
.coerce(value) ⇒ ::Time
Coerces a value into a Time object.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/parameters/types/time.rb', line 18 def self.coerce(value) case value when Integer ::Time.at(value) else if value.respond_to?(:to_time) value.to_time else ::Time.parse(value.to_s) end end end |