Module: Opendistro::Configuration
- Included in:
- Opendistro
- Defined in:
- lib/opendistro/configuration.rb
Overview
Defines constants and methods related to configuration.
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Opendistro::API.
%i[endpoint username password ca_cert httparty user_agent verify_ssl].freeze
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set.
"Opendistro Ruby Gem #{Opendistro::VERSION}"
- DEFAULT_VERIFY_SSL =
true
Class Method Summary collapse
-
.extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Creates a hash of options and their values.
-
#reset ⇒ Object
Resets all configuration options to the defaults.
Class Method Details
.extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
17 18 19 |
# File 'lib/opendistro/configuration.rb', line 17 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
22 23 24 |
# File 'lib/opendistro/configuration.rb', line 22 def configure yield self end |
#options ⇒ Object
Creates a hash of options and their values.
27 28 29 30 31 |
# File 'lib/opendistro/configuration.rb', line 27 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Resets all configuration options to the defaults.
34 35 36 37 38 39 40 41 42 |
# File 'lib/opendistro/configuration.rb', line 34 def reset self.endpoint = ENV['OPENDISTRO_API_ENDPOINT'] self.username = ENV['OPENDISTRO_API_USER'] self.password = ENV['OPENDISTRO_API_PASSWORD'] self.ca_cert = ENV['OPENDISTRO_API_CA_CERT_PATH'] self.httparty = get_httparty_config(ENV['OPENDISTRO_API_HTTPARTY_OPTIONS']) self.user_agent = DEFAULT_USER_AGENT self.verify_ssl = ENV['OPENDISTRO_API_VERIFY_SSL'] || DEFAULT_VERIFY_SSL end |