Sha256: bd68b9d4abb6e4fe56106851f3573bef925041983872e80acf923d4a32b2fb60

Contents?: true

Size: 720 Bytes

Versions: 10

Compression:

Stored size: 720 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Synonyms
    RESOURCE_PATH = '/synonyms'

    def initialize(collection_name, api_call)
      @collection_name = collection_name
      @api_call        = api_call
      @synonyms = {}
    end

    def upsert(synonym_id, params)
      @api_call.put(endpoint_path(synonym_id), params)
    end

    def retrieve
      @api_call.get(endpoint_path)
    end

    def [](synonym_id)
      @synonyms[synonym_id] ||= Synonym.new(@collection_name, synonym_id, @api_call)
    end

    private

    def endpoint_path(operation = nil)
      "#{Collections::RESOURCE_PATH}/#{@collection_name}#{Synonyms::RESOURCE_PATH}#{operation.nil? ? '' : "/#{operation}"}"
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
typesense-1.1.0 lib/typesense/synonyms.rb
typesense-1.0.0 lib/typesense/synonyms.rb
typesense-0.15.0 lib/typesense/synonyms.rb
typesense-0.14.1 lib/typesense/synonyms.rb
typesense-0.14.0 lib/typesense/synonyms.rb
typesense-0.13.0 lib/typesense/synonyms.rb
typesense-0.12.0 lib/typesense/synonyms.rb
typesense-0.11.1 lib/typesense/synonyms.rb
typesense-0.11.0 lib/typesense/synonyms.rb
typesense-0.10.0 lib/typesense/synonyms.rb