Sha256: 3f7161c872a6893dca86b0d363e444ebc5e5b6d4219c09d5afd4a9c888333ada

Contents?: true

Size: 737 Bytes

Versions: 10

Compression:

Stored size: 737 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}/#{@collection_name}#{Overrides::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/overrides.rb
typesense-1.0.0 lib/typesense/overrides.rb
typesense-0.15.0 lib/typesense/overrides.rb
typesense-0.14.1 lib/typesense/overrides.rb
typesense-0.14.0 lib/typesense/overrides.rb
typesense-0.13.0 lib/typesense/overrides.rb
typesense-0.12.0 lib/typesense/overrides.rb
typesense-0.11.1 lib/typesense/overrides.rb
typesense-0.11.0 lib/typesense/overrides.rb
typesense-0.10.0 lib/typesense/overrides.rb