Class: ActiveAttr::Typecasting::DateTimeTypecaster
- Inherits:
-
Object
- Object
- ActiveAttr::Typecasting::DateTimeTypecaster
- Defined in:
- lib/active_attr/typecasting/date_time_typecaster.rb
Overview
Typecasts an Object to a DateTime
Instance Method Summary collapse
-
#call(value) ⇒ DateTime?
Typecasts an object to a DateTime.
Instance Method Details
#call(value) ⇒ DateTime?
Typecasts an object to a DateTime
Attempts to convert using #to_datetime.
26 27 28 29 |
# File 'lib/active_attr/typecasting/date_time_typecaster.rb', line 26 def call(value) value.to_datetime if value.respond_to? :to_datetime rescue ArgumentError end |