Sha256: 98c77f7e7b1f3fe4ee4a9c67b35291e5705f01d1500996b2e90641623428d47e
Contents?: true
Size: 776 Bytes
Versions: 6
Compression:
Stored size: 776 Bytes
Contents
# frozen_string_literal: true using SmartCore::Ext::BasicObjectAsObject # @api public # @since 0.1.0 # @version 0.3.0 SmartCore::Types::Value.define_type(:Numeric) do |type| type.define_checker do |value| value.is_a?(::Numeric) end type.define_caster do |value| next value if value.is_a?(::Numeric) begin SmartCore::Types::Value::Float.cast(value) rescue SmartCore::Types::TypeCastingError begin SmartCore::Types::Value::Integer.cast(value) rescue SmartCore::Types::TypeCastingError begin SmartCore::Types::Value::BigDecimal.cast(value) rescue SmartCore::Types::TypeCastingError raise(SmartCore::Types::TypeCastingError, 'Non-castable to Numeric') end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems