Sha256: 13238824b3d849818ea1a11bddb2bbd03c405c3b671ce31779d27a4f69869e3a

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module Typesense
  class Aliases
    RESOURCE_PATH = '/aliases'

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

    def upsert(alias_name, mapping)
      ApiCall.new(@configuration).put(endpoint_path(alias_name), mapping)
    end

    def retrieve
      ApiCall.new(@configuration).get(RESOURCE_PATH)
    end

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

    private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typesense-0.2.0 lib/typesense/aliases.rb