Sha256: 1500041c4e58a04004c7442e051cf0c36f2dba03cc7bac202d2cb3ad04783527

Contents?: true

Size: 668 Bytes

Versions: 10

Compression:

Stored size: 668 Bytes

Contents

# typed: false
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?
    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)
    other.is_a?(IntegerString)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sorbet-rails-0.6.2 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.6.1 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.6.0 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.9.1 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.9 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.8.1 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.8 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.7 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.6 lib/sorbet-rails/custom_types/integer_string.rb
sorbet-rails-0.5.5.1 lib/sorbet-rails/custom_types/integer_string.rb