Class: OpenAI::Internal::Type::Unknown Abstract Private
- Inherits:
-
Object
- Object
- OpenAI::Internal::Type::Unknown
- Extended by:
- Converter, Util::SorbetRuntimeSupport
- Defined in:
- lib/openai/internal/type/unknown.rb,
sig/openai/internal/type/unknown.rbs
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
When we don't know what to expect for the value.
Direct Known Subclasses
Class Method Summary collapse
- .==(other) ⇒ Boolean
- .===(other) ⇒ Boolean
-
.coerce(value, state:) ⇒ Object
private
No coercion needed for Unknown type.
-
.dump(value, state:) ⇒ Object
private
Traverse arbitrary JSON containers without consuming the Ruby stack.
- .to_sorbet_type ⇒ Object private
Methods included from Converter
coerce, coerce_cached, coerce_with_error, dump, inspect, inspect, meta_info, new_coerce_state, resolve_type, type_info
Methods included from Util::SorbetRuntimeSupport
const_missing, define_sorbet_constant!, sorbet_constant_defined?, to_sorbet_type
Class Method Details
.==(other) ⇒ Boolean
31 |
# File 'lib/openai/internal/type/unknown.rb', line 31 def self.==(other) = other.is_a?(Class) && other <= OpenAI::Internal::Type::Unknown |
.===(other) ⇒ Boolean
24 |
# File 'lib/openai/internal/type/unknown.rb', line 24 def self.===(other) = true |
.coerce(value, state:) ⇒ 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.
No coercion needed for Unknown type.
53 54 55 56 |
# File 'lib/openai/internal/type/unknown.rb', line 53 def coerce(value, state:) state.fetch(:exactness)[:yes] += 1 value end |
.dump(value, state:) ⇒ 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.
Traverse arbitrary JSON containers without consuming the Ruby stack. Delegate model, file, and scalar conversion to the existing converter.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/openai/internal/type/unknown.rb', line 70 def dump(value, state:) return super unless value.is_a?(Hash) || value.is_a?(Array) result = value.is_a?(Hash) ? {} : [] copies = {}.compare_by_identity copies[value] = result pending = [[value, result]] until pending.empty? source, destination = pending.pop entries = source.is_a?(Hash) ? source.each_pair : source.each_with_index.lazy.map { |item, i| [i, item] } entries.each do |key, item| if item.is_a?(Hash) || item.is_a?(Array) unless copies.key?(item) copies[item] = item.is_a?(Hash) ? {} : [] pending << [item, copies.fetch(item)] end destination[key] = copies.fetch(item) else destination[key] = super(item, state: state) end end end result end |
.to_sorbet_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.
100 101 102 |
# File 'lib/openai/internal/type/unknown.rb', line 100 def to_sorbet_type T.anything end |