module Elastic::WorkplaceSearch::Configuration

Constants

DEFAULT_ENDPOINT
VALID_OPTIONS_KEYS

Public Class Methods

extended(base) click to toggle source
# File lib/elastic/workplace-search/configuration.rb, line 17
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

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

@return self

# File lib/elastic/workplace-search/configuration.rb, line 32
def configure
  yield self
  self
end
endpoint=(endpoint) click to toggle source

setter for endpoint that ensures it always ends in '/'

# File lib/elastic/workplace-search/configuration.rb, line 45
def endpoint=(endpoint)
  if endpoint.end_with?('/')
    @endpoint = endpoint
  else
    @endpoint = "#{endpoint}/"
  end
end
options() click to toggle source

Return a hash of the configured options.

# File lib/elastic/workplace-search/configuration.rb, line 38
def options
  options = {}
  VALID_OPTIONS_KEYS.each{ |k| options[k] = send(k) }
  options
end
reset() click to toggle source

Reset configuration to default values.

# File lib/elastic/workplace-search/configuration.rb, line 22
def reset
  self.access_token = nil
  self.endpoint = DEFAULT_ENDPOINT
  self.user_agent = nil
  self
end