class Env

Public Class Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/environs/env.rb, line 5
def method_missing(method, *args, &block)
  key = method.to_s.upcase
  key.match(/\w+/) ? env_key(key, *args) : super
end

Private Class Methods

env_key(key, nil_allowance = {}) click to toggle source
# File lib/environs/env.rb, line 12
def env_key(key, nil_allowance = {})
  ENV.fetch(key) { |k| key_not_found(nil_allowance, key) }
end
env_var_error(key) click to toggle source
# File lib/environs/env.rb, line 20
def env_var_error(key)
  raise MissingEnvVarError, "The #{key} environment variable is not set."
end
key_not_found(nil_allowance, key) click to toggle source
# File lib/environs/env.rb, line 16
def key_not_found(nil_allowance, key)
  nil_allowance[:allow_nil] ? nil : env_var_error(key)
end