Class: Env
- Inherits:
-
Object
- Object
- Env
- Defined in:
- lib/environs/env.rb
Class Method Summary collapse
- .key_not_found_response(potential_hash, key) ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
Class Method Details
.key_not_found_response(potential_hash, key) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/environs/env.rb', line 14 def key_not_found_response(potential_hash, key) if potential_hash.respond_to?(:fetch) && potential_hash.fetch(:allow_nil) nil else raise MissingEnvVarError, "The #{key} environment variable is not set." end end |
.method_missing(method, *args, &block) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/environs/env.rb', line 5 def method_missing(method, *args, &block) key = method.to_s.upcase if key.match(/\w+/) ENV[key] || key_not_found_response(args.first, key) else super end end |