Sha256: cab0beea38536cf57d8a9f5013db1c04482db648fdf5f33236194678003e84b2

Contents?: true

Size: 444 Bytes

Versions: 6

Compression:

Stored size: 444 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(: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

6 entries across 6 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/value/string.rb
smart_types-0.7.1 lib/smart_core/types/value/string.rb
smart_types-0.7.0 lib/smart_core/types/value/string.rb
smart_types-0.6.0 lib/smart_core/types/value/string.rb
smart_types-0.4.0 lib/smart_core/types/value/string.rb
smart_types-0.3.0 lib/smart_core/types/value/string.rb