Class: Pinecone::Vector::Query

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/pinecone/vector/query.rb

Defined Under Namespace

Classes: QueryContract

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(input) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/pinecone/vector/query.rb', line 44

def self.new(input)
  validation = QueryContract.new.call(input)
  if validation.success?
    super
  else
    raise ArgumentError.new(validation.errors.to_h.inspect)
  end
end

Instance Method Details

#to_jsonObject



53
54
55
56
57
58
59
# File 'lib/pinecone/vector/query.rb', line 53

def to_json
  to_h.map do |key, value|
    [key.to_s.split("_").map.with_index do |word, index|
      (index == 0) ? word : word.capitalize
    end.join.to_sym, value]
  end.to_h.to_json
end