Module: Appydays::Configurable

Class Method Summary collapse

Class Method Details

.fetch_env(keys, default = :__keyerror, env: ENV) ⇒ Object

Raises:

  • (KeyError)


23
24
25
26
27
28
29
30
# File 'lib/webhookdb.rb', line 23

def self.fetch_env(keys, default=:__keyerror, env: ENV)
  keys = [keys] unless keys.respond_to?(:to_ary)
  keys.to_ary.each do |k|
    return env.fetch(k) if env.key?(k)
  end
  raise KeyError, "no key found in env: #{keys}" if default == :__keyerror
  return default
end