Class: Turbopuffer::Models::Row
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- Turbopuffer::Models::Row
- Defined in:
- lib/turbopuffer/models/row.rb
Instance Attribute Summary collapse
-
#id ⇒ String, Integer
An identifier for a document.
-
#vector ⇒ Array<Float>, ...
A vector embedding associated with a document.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize(id: , vector: nil) ⇒ Object
constructor
A single document, in a row-based format.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Methods inherited from Internal::Type::BaseModel
==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml
Methods included from Internal::Type::Converter
#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(id: , vector: nil) ⇒ Object
A single document, in a row-based format.
25 26 27 28 29 30 31 |
# File 'lib/turbopuffer/models/row.rb', line 25 def method_missing(name, *args, &block) if @data.key?(name) @data[name] else super end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/turbopuffer/models/row.rb', line 25 def method_missing(name, *args, &block) if @data.key?(name) @data[name] else super end end |
Instance Attribute Details
#id ⇒ String, Integer
An identifier for a document.
10 |
# File 'lib/turbopuffer/models/row.rb', line 10 required :id, union: -> { Turbopuffer::ID } |
#vector ⇒ Array<Float>, ...
A vector embedding associated with a document.
16 |
# File 'lib/turbopuffer/models/row.rb', line 16 optional :vector, union: -> { Turbopuffer::Vector } |
Instance Method Details
#[]=(key, value) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/turbopuffer/models/row.rb', line 37 def []=(key, value) unless key.instance_of?(Symbol) raise ArgumentError.new("Expected symbol key for set, got #{key.inspect}") end @data[key] = value end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
33 34 35 |
# File 'lib/turbopuffer/models/row.rb', line 33 def respond_to_missing?(name, include_private = false) @data.key?(name) || super end |