Sha256: ae7be32753f67c6f2df6961380e593e46ed2d61dcf597a4f91ec243dc6296e92
Contents?: true
Size: 548 Bytes
Versions: 3
Compression:
Stored size: 548 Bytes
Contents
# frozen_string_literal: true require 'date' using SmartCore::Ext::BasicObjectAsObject # @api public # @since 0.1.0 # @version 0.7.0 SmartCore::Types::Value.define_type(:Date) do |type| type.define_checker do |value| value.is_a?(::Date) || value == ::Date::Infinity end type.define_caster do |value| next value if value.is_a?(::Date) || value == ::Date::Infinity begin ::Date.parse(value) rescue ::ArgumentError, ::TypeError raise(SmartCore::Types::TypeCastingError, 'Non-castable to Date') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.8.0 | lib/smart_core/types/value/date.rb |
smart_types-0.7.1 | lib/smart_core/types/value/date.rb |
smart_types-0.7.0 | lib/smart_core/types/value/date.rb |