class Morf::Casters::TimeCaster
Public Class Methods
cast(value, attr_name, options = {})
click to toggle source
# File lib/morf/casters/time_caster.rb, line 4 def self.cast(value, attr_name, options = {}) if value.is_a?(Time) value elsif value.is_a?(String) begin Time.parse(value) rescue ArgumentError => e raise Morf::Errors::CastingError, "is invalid time" end else raise Morf::Errors::CastingError, "should be a time" end end