Sha256: 1f612e633bbeae85bac1324ae7d53e26dec0bb7340d50631dca6855fb0a14887
Contents?: true
Size: 689 Bytes
Versions: 2
Compression:
Stored size: 689 Bytes
Contents
# frozen_string_literal: true # @api public # @since 0.1.0 SmartCore::Types::Value::Text = SmartCore::Types::System.type_sum( SmartCore::Types::Value::String, SmartCore::Types::Value::Symbol ) do |type| type.define_caster do |value| next value if SmartCore::Types::Value::String.valid?(value) next value if SmartCore::Types::Value::Symbol.valid?(value) begin SmartCore::Types::Value::String.cast(value) rescue SmartCore::Types::TypeCastingError begin SmartCore::Types::Value::Symbol.cast(value) rescue SmartCore::Types::TypeCastingError raise(SmartCore::Types::TypeCastingError, 'Non-castable to text') 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/text.rb |
smart_types-0.1.0 | lib/smart_core/types/value/text.rb |