Sha256: 7a58f4f6a555c0b8ee39d11cd321f92e077b72ea5beae1d644d147aa39049614

Contents?: true

Size: 384 Bytes

Versions: 2

Compression:

Stored size: 384 Bytes

Contents

# frozen_string_literal: true

# @api public
# @since 0.1.0
SmartCore::Types::Value.define_type(:String) do |type|
  type.define_checker do |value|
    value.is_a?(::String)
  end

  type.define_caster do |value|
    begin
      ::Kernel.String(value)
    rescue ::TypeError, ::ArgumentError
      raise(SmartCore::Types::TypeCastingError, 'Non-castable to String')
    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/string.rb
smart_types-0.1.0 lib/smart_core/types/value/string.rb