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