Sha256: 61c9c3c65217d5d90b0cff9ec7d981f6c8ab9a10586f7970155e6ad383811955

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

require 'elasticsearch'

module Mindex
  class Elasticsearch < Delegator
    def self.connect(options = {})
      new({
        url:      Mindex.config.elasticsearch_url,
        user:     Mindex.config.elasticsearch_user,
        password: Mindex.config.elasticsearch_pass
      }.merge(Mindex.config.elasticsearch_options || {}).merge(options || {}))
    end

    def version
      info['version']['number']
    end

    def version_gte?(expected_version)
      Gem::Version.new(version) >= Gem::Version.new(expected_version)
    end

    def initialize(options)
      @delegate_sd_obj ||= ::Elasticsearch::Client.new(options)
    end

    def __getobj__
      @delegate_sd_obj
    end

    def __setobj__(obj)
      @delegate_sd_obj = obj
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mindex-0.2.0 lib/mindex/elasticsearch.rb
mindex-0.1.0 lib/mindex/elasticsearch.rb