Sha256: 1a54f8a40f2908b6211a4d9e15b35a90265d70d4ddc2428cd2169e026e1cdf77

Contents?: true

Size: 704 Bytes

Versions: 4

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Document
    def initialize(collection_name, document_id, api_call)
      @collection_name = collection_name
      @document_id     = document_id
      @api_call        = api_call
    end

    def retrieve
      @api_call.get(endpoint_path)
    end

    def delete
      @api_call.delete(endpoint_path)
    end

    def update(partial_document, options = {})
      @api_call.patch(endpoint_path, partial_document, options)
    end

    private

    def endpoint_path
      "#{Collections::RESOURCE_PATH}/#{URI.encode_www_form_component(@collection_name)}#{Documents::RESOURCE_PATH}/#{URI.encode_www_form_component(@document_id)}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typesense-3.0.0.rc1 lib/typesense/document.rb
typesense-2.1.0 lib/typesense/document.rb
typesense-2.1.0.rc2 lib/typesense/document.rb
typesense-2.1.0.rc1 lib/typesense/document.rb