Module: Anthropic::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.

Parameters:

  • type (Anthropic::Internal::Util::SorbetRuntimeSupport, Object)

Returns:

  • (Object)


989
990
991
992
993
994
995
996
997
998
999
1000
# File 'lib/anthropic/internal/util.rb', line 989

def to_sorbet_type(type)
  case type
  in Anthropic::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) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • name (Symbol)


954
955
956
957
958
959
960
961
962
963
# File 'lib/anthropic/internal/util.rb', line 954

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) { ... } ⇒ void

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.

This method returns an undefined value.

Parameters:

  • name (Symbol)
  • blk (Proc)

Yields:

Yield Returns:

  • (top)


976
# File 'lib/anthropic/internal/util.rb', line 976

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:



970
# File 'lib/anthropic/internal/util.rb', line 970

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:

  • (Object)

Raises:

  • (NotImplementedError)


981
# File 'lib/anthropic/internal/util.rb', line 981

def to_sorbet_type = raise NotImplementedError