Sha256: de93f5071ed565fd6ee0762307f6a1fa0e09169a09219c3c8a1064366ab6af31
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true # @api public # @since 0.1.0 SmartCore::Types::Value::TimeBased = SmartCore::Types::System.type_sum( SmartCore::Types::Value::Time, SmartCore::Types::Value::DateTime, SmartCore::Types::Value::Date ) do |type| type.define_caster do |value| next value if SmartCore::Types::Value::Time.valid?(value) next value if SmartCore::Types::Value::DateTime.valid?(value) next value if SmartCore::Types::Value::Date.valid?(value) begin SmartCore::Types::Value::Time.cast(value) rescue SmartCore::Types::TypeCastingError begin SmartCore::Types::Value::DateTime.cast(value) rescue SmartCore::Types::TypeCastingError begin SmartCore::Types::Value::Date.cast(value) rescue SmartCore::Types::TypeCastingError raise(SmartCore::Types::TypeCastingError, 'Non-castable to time-based type') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_types-0.2.0 | lib/smart_core/types/value/time_based.rb |
smart_types-0.1.0 | lib/smart_core/types/value/time_based.rb |