Module: OpenAI::Internal::Util::SorbetRuntimeSupport Private

Included in:
OpenAI::Internal, Transport::BaseClient, Type::ArrayOf, Type::BaseModel, Type::Boolean, Type::Converter, Type::Enum, Type::HashOf, Type::Union, Type::Unknown
Defined in:
lib/openai/internal/util.rb,
sig/openai/internal/util.rbs

Overview

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.

API:

  • private

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:

Returns:

API:

  • private



1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
# File 'lib/openai/internal/util.rb', line 1031

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

API:

  • private



996
997
998
999
1000
1001
1002
1003
1004
1005
# File 'lib/openai/internal/util.rb', line 996

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:

Yields:

Yield Returns:

  • (top)

API:

  • private



1018
# File 'lib/openai/internal/util.rb', line 1018

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:

Returns:

API:

  • private



1012
# File 'lib/openai/internal/util.rb', line 1012

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:

API:

  • private



1023
# File 'lib/openai/internal/util.rb', line 1023

def to_sorbet_type = raise NotImplementedError