Module: Knockapi::Internal::Util::SorbetRuntimeSupport Private

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: MissingSorbetRuntimeError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_sorbet_type(type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



874
875
876
877
878
879
880
881
882
883
884
885
# File 'lib/knockapi/internal/util.rb', line 874

def to_sorbet_type(type)
  case type
  in Knockapi::Internal::Util::SorbetRuntimeSupport
    type.to_sorbet_type
  in Class | Module
    type
  in true | false
    T::Boolean
  else
    type.class
  end
end

Instance Method Details

#const_missing(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (Symbol)


839
840
841
842
843
844
845
846
847
848
# File 'lib/knockapi/internal/util.rb', line 839

def const_missing(name)
  super unless sorbet_runtime_constants.key?(name)

  unless Object.const_defined?(:T)
    message = "Trying to access a Sorbet constant #{name.inspect} without `sorbet-runtime`."
    raise MissingSorbetRuntimeError.new(message)
  end

  sorbet_runtime_constants.fetch(name).call
end

#define_sorbet_constant!(name, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (Symbol)
  • blk (Proc)


861
# File 'lib/knockapi/internal/util.rb', line 861

def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk)

#sorbet_constant_defined?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)


855
# File 'lib/knockapi/internal/util.rb', line 855

def sorbet_constant_defined?(name) = sorbet_runtime_constants.key?(name)

#to_sorbet_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Raises:

  • (NotImplementedError)


866
# File 'lib/knockapi/internal/util.rb', line 866

def to_sorbet_type = raise NotImplementedError