Class: Envlogic::Env
- Inherits:
-
String
- Object
- String
- Envlogic::Env
- Defined in:
- lib/envlogic/env.rb
Overview
Env module to get and set environment
Instance Method Summary collapse
-
#initialize(klass) ⇒ Envlogic::Env
constructor
Envlogic env object].
-
#method_missing(method_name, *arguments) ⇒ Object
Reacts to missing methods, from which some might be the env checkings.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
True if we respond to a given missing method, otherwise false.
Constructor Details
#initialize(klass) ⇒ Envlogic::Env
Note:
Will load appropriate environment automatically
Returns envlogic env object].
26 27 28 29 30 31 32 |
# File 'lib/envlogic/env.rb', line 26 def initialize(klass) env = ENV[to_env_key(app_dir_name)] env ||= ENV[to_env_key(klass.to_s)] env ||= ENV[FALLBACK_ENV_KEY] update(env || FALLBACK_ENV) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object
Reacts to missing methods, from which some might be the env checkings. If the method ends with ‘?’ we assume, that it is an env check
45 46 47 |
# File 'lib/envlogic/env.rb', line 45 def method_missing(method_name, *arguments) method_name[-1] == '?' ? self == method_name[0..-2] : super end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Returns true if we respond to a given missing method, otherwise false.
37 38 39 |
# File 'lib/envlogic/env.rb', line 37 def respond_to_missing?(method_name, include_private = false) (method_name[-1] == '?') || super end |