Sha256: f053c4ddfef6acc213ee38e8a64ca5b93b777858e9a80cda9b855c47e2a58e3c

Contents?: true

Size: 587 Bytes

Versions: 3

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Presets
    RESOURCE_PATH = '/presets'

    def initialize(api_call)
      @api_call = api_call
      @presets = {}
    end

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

    def retrieve
      @api_call.get(endpoint_path)
    end

    def [](preset_name)
      @presets[preset_name] ||= Preset.new(preset_name, @api_call)
    end

    private

    def endpoint_path(operation = nil)
      "#{Presets::RESOURCE_PATH}#{operation.nil? ? '' : "/#{operation}"}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typesense-1.1.0 lib/typesense/presets.rb
typesense-1.0.0 lib/typesense/presets.rb
typesense-0.15.0 lib/typesense/presets.rb