Module: Configurate::Provider

Defined in:
lib/configurate/provider.rb,
lib/configurate/provider/env.rb,
lib/configurate/provider/yaml.rb,
lib/configurate/provider/dynamic.rb

Defined Under Namespace

Classes: Base, Dynamic, Env, YAML

Class Method Summary collapse

Class Method Details

.lookup_in_hash(setting_path, hash) { ... } ⇒ Object

Utility function to lookup a settings path in a hash

Parameters:

Yields:

  • fallback value if not found

Returns:

  • (Object)

21
22
23
24
25
26
27
28
# File 'lib/configurate/provider.rb', line 21

def self.lookup_in_hash setting_path, hash, &fallback
  fallback ||= proc { nil }
  while hash.is_a?(Hash) && hash.has_key?(setting_path.first) && !setting_path.empty?
    hash = hash[setting_path.shift]
  end
  return fallback.call unless setting_path.empty?
  hash
end