Module: ThreeScale::Backend::Storage::Helpers
- Defined in:
- lib/3scale/backend/storage_helpers.rb
Class Method Summary collapse
-
.config_with(config, options: {}, whitelist: CONFIG_WHITELIST, defaults: CONN_OPTIONS) ⇒ Object
Generate an options hash suitable for Redis.new’s constructor.
Class Method Details
.config_with(config, options: {}, whitelist: CONFIG_WHITELIST, defaults: CONN_OPTIONS) ⇒ Object
Generate an options hash suitable for Redis.new’s constructor
The options hash will overwrite any settings in the configuration, and will also accept a special “default_url” parameter to apply when no URL-related parameters are passed in (both in configuration and in options).
The whitelist and defaults keyword parameters control the whitelisted configuration keys to add to the Redis parameters and the default values for unspecified keys. This way you don’t need to rely on hardcoded defaults.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/3scale/backend/storage_helpers.rb', line 91 def config_with(config, options: {}, whitelist: CONFIG_WHITELIST, defaults: CONN_OPTIONS) = parse_dbcfg(config) cfg = whitelist.each_with_object({}) do |k, h| val = [k] h[k] = val if val end.merge() cfg_with_sentinels = cfg_sentinels_handler cfg defaults.merge(ensure_url_param(cfg_with_sentinels)) end |