Sha256: 694c0b65053b9303c24da458352ba1cb7c7aec6f1bc3393d53ce9f9226366f9a

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

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

module BooleanStringImpl
  def is_a?(type)
    return super unless type == BooleanString
    _is_a_boolean_string?
  end

  def kind_of?(type)
    return super unless type == BooleanString
    _is_a_boolean_string?
  end

  def instance_of?(type)
    return super unless type == BooleanString
    _is_a_boolean_string?
  end

  def _is_a_boolean_string?
    return @cached_is_a unless @cached_is_a.nil?
    SorbetRails::TypeAssertDeprecation.deprecation_warning(
      :BooleanString,
      'Use TypedParam with T::Boolean type instead.'
    )
    @cached_is_a = (self =~ /^(true|false)$/i) == 0
  end
end

class String
  include BooleanStringImpl
end

class BooleanString < String
  def self.===(other)
    SorbetRails::TypeAssertDeprecation.deprecation_warning(
      :BooleanString,
      'Use TypedParam with T::Boolean type instead.'
    )
    other.is_a?(BooleanString)
  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/boolean_string.rb
sorbet-rails-0.6.5 lib/sorbet-rails/custom_types/boolean_string.rb
sorbet-rails-0.6.4 lib/sorbet-rails/custom_types/boolean_string.rb
sorbet-rails-0.6.3 lib/sorbet-rails/custom_types/boolean_string.rb