Sha256: 94c69057a7b506615156101726605d2310d49f148b468996d43fc4f04f2d90ab

Contents?: true

Size: 799 Bytes

Versions: 4

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Overrides
    RESOURCE_PATH = '/overrides'

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

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

    def retrieve
      @api_call.get(endpoint_path)
    end

    def [](override_id)
      @overrides[override_id] ||= Override.new(@collection_name, override_id, @api_call)
    end

    private

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

Version data entries

4 entries across 4 versions & 1 rubygems

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