module Elastic::SiteSearch::Configuration

Constants

DEFAULT_ENDPOINT
VALID_OPTIONS_KEYS

Public Class Methods

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

Public Instance Methods

authenticated_url=(url) click to toggle source

Set api_key and endpoint based on a URL with HTTP authentication.

# File lib/elastic/site-search/configuration.rb, line 49
def authenticated_url=(url)
  uri = URI(url)
  self.api_key = uri.user
  uri.user = nil
  uri.password = nil
  self.endpoint = uri.to_s
end
configure() { |self| ... } click to toggle source

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

@return self

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

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

# File lib/elastic/site-search/configuration.rb, line 58
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/site-search/configuration.rb, line 42
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/site-search/configuration.rb, line 24
def reset
  self.api_key = nil
  self.endpoint = DEFAULT_ENDPOINT
  self.user_agent = nil
  self.platform_client_id = nil
  self.platform_client_secret = nil
  self
end