Sha256: e39e65dd59aafc35a8de5351054a0d7180089f5d3568fd3b02c9cdd09d2cdeac

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

# typed: false
require('sorbet-rails/deprecation.rb')

module IntegerStringImpl
  def is_a?(type)
    return super unless type == IntegerString
    _is_a_integer_string?
  end

  def kind_of?(type)
    return super unless type == IntegerString
    _is_a_integer_string?
  end

  def instance_of?(type)
    return super unless type == IntegerString
    _is_a_integer_string?
  end

  def _is_a_integer_string?
    return @cached_is_a unless @cached_is_a.nil?
    SorbetRails::TypeAssertDeprecation.deprecation_warning(
      :IntegerString,
      'Use TypedParams with Integer type instead.'
    )
    Integer(self, 10)
    @cached_is_a = true
  rescue ArgumentError => err
    @cached_is_a = false
  end
end

class String
  include IntegerStringImpl
end

class IntegerString < String
  def self.===(other)
    SorbetRails::TypeAssertDeprecation.deprecation_warning(
      :IntegerString,
      'Use TypedParams with Integer type instead.'
    )
    other.is_a?(IntegerString)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sorbet-rails-0.6.5.1 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.6.5 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.6.4 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.6.3 lib/sorbet-rails/custom_types/integer_string.rb