Module: Elastic::EnterpriseSearch::Configuration

Defined in:
lib/elastic/enterprise-search/configuration.rb

Overview

Configuratin module

Constant Summary collapse

VALID_OPTIONS_KEYS =

TODO: Endpoint for EE DEFAULT_ENDPOINT = ‘localhost:3002/api/ws/v1/’

[:access_token, :endpoint].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



34
35
36
# File 'lib/elastic/enterprise-search/configuration.rb', line 34

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields the Elastic::WorkplaceSearch::Configuration module which can be used to set configuration options.

Yields:

  • (_self)

Yield Parameters:

Returns:

  • self



48
49
50
51
# File 'lib/elastic/enterprise-search/configuration.rb', line 48

def configure
  yield self
  self
end

#endpoint=(endpoint) ⇒ Object

setter for endpoint that ensures it always ends in ‘/’



61
62
63
64
65
66
67
# File 'lib/elastic/enterprise-search/configuration.rb', line 61

def endpoint=(endpoint)
  @endpoint = if endpoint.end_with?('/')
                endpoint
              else
                "#{endpoint}/"
              end
end

#optionsObject

Return a hash of the configured options.



54
55
56
57
58
# File 'lib/elastic/enterprise-search/configuration.rb', line 54

def options
  options = {}
  VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
  options
end

#resetObject

Reset configuration to default values.



39
40
41
42
43
# File 'lib/elastic/enterprise-search/configuration.rb', line 39

def reset
  self.access_token = nil
  self.endpoint = DEFAULT_ENDPOINT
  self
end