Sha256: 4d6d917afd52d5d199cc108462fb67e5330190bc65ce15287d441f8b3ce52bb5

Contents?: true

Size: 583 Bytes

Versions: 4

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Aliases
    RESOURCE_PATH = '/aliases'

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

    def upsert(alias_name, mapping)
      @api_call.put(endpoint_path(alias_name), mapping)
    end

    def retrieve
      @api_call.get(RESOURCE_PATH)
    end

    def [](alias_name)
      @aliases[alias_name] ||= Alias.new(alias_name, @api_call)
    end

    private

    def endpoint_path(alias_name)
      "#{Aliases::RESOURCE_PATH}/#{URI.encode_www_form_component(alias_name)}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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