Class: AttrTypecastable::Types::Time
- Defined in:
- lib/attr_typecastable/types/time.rb
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from AttrTypecastable::Types::Base
Instance Method Details
#do_typecast(value) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/attr_typecastable/types/time.rb', line 9 def do_typecast(value) return value if value.is_a?(::Time) if value.respond_to?(:to_time) value.to_time else raise CastError, "value does not have `to_time` method" end end |