Class: Common::DateTimeString
- Inherits:
-
Virtus::Attribute
- Object
- Virtus::Attribute
- Common::DateTimeString
- Defined in:
- lib/common/models/attribute_types/date_time_string.rb
Overview
Ensures that a string can be parsed to a valid DateTime
Instance Method Summary collapse
Instance Method Details
#coerce(value) ⇒ Object
6 7 8 9 10 |
# File 'lib/common/models/attribute_types/date_time_string.rb', line 6 def coerce(value) value if value.is_a?(::String) && Time.parse(value).iso8601 rescue ArgumentError nil end |