Sha256: 41ddea799b79d78e35280b9422ccbb7cabbd061f46da7ffced9a6523cf5673d8
Contents?: true
Size: 403 Bytes
Versions: 3
Compression:
Stored size: 403 Bytes
Contents
require 'date' class HashCast::Casters::DateCaster 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 HashCast::Errors::CastingError, "is invalid date" end else raise HashCast::Errors::CastingError, "should be a date" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hash_cast-0.5.2 | lib/hash_cast/casters/date_caster.rb |
hash_cast-0.5.1 | lib/hash_cast/casters/date_caster.rb |
hash_cast-0.5.0 | lib/hash_cast/casters/date_caster.rb |