Sha256: d8a561b9e033206b783ad1b9965e00634d7d17c3f5e5d3f872bc67e26e8c4c43

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'forwardable'

module Esse
  module Backend
    class Index
      require_relative 'index/aliases'
      require_relative 'index/create'
      require_relative 'index/delete'
      require_relative 'index/existance'
      require_relative 'index/update'
      require_relative 'index/refresh'
      require_relative 'index/reset'
      require_relative 'index/documents'
      require_relative 'index/open'
      require_relative 'index/close'

      extend Forwardable

      NAMING = %i[index_version].freeze
      DEFINITION = %i[settings_hash mappings_hash].freeze

      def_delegators :@index, :type_hash, *(NAMING + DEFINITION)

      def initialize(index)
        @index = index
      end

      protected

      def index_name(suffix: nil)
        suffix = Hstring.new(suffix).underscore.presence
        return @index.index_name unless suffix

        [@index.index_name, suffix].join('_')
      end

      def build_real_index_name(suffix = nil)
        suffix = Hstring.new(suffix).underscore.presence || index_version || Esse.timestamp

        index_name(suffix: suffix)
      end

      def client
        cluster.client
      end

      def cluster
        @index.cluster
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
esse-0.2.0 lib/esse/backend/index.rb
esse-0.1.3 lib/esse/backend/index.rb
esse-0.1.2 lib/esse/backend/index.rb
esse-0.1.1 lib/esse/backend/index.rb