Class: Ghaki::Env::Engine
- Inherits:
-
Object
- Object
- Ghaki::Env::Engine
- Includes:
- Singleton
- Defined in:
- lib/ghaki/env/engine.rb
Overview
Run time environment discovery singleton.
-
Detects GHAKI_RUN_ENV, RAILS_ENV, RACK_ENV in environment.
-
Detects the RAILS_ENV global constant.
-
Detects Sinatra and Merb classes in the Ruby namespace.
Examples
Ghaki::Env.instance.clear_environment
RACK_ENV = 'testing'
Ghaki::Env.instance.environment #=> 'testing'
Instance Method Summary collapse
-
#assert_environment ⇒ Object
Throw an exception if the environment is not valid.
-
#clear_environment ⇒ Object
Clears current set environment.
-
#detect_environment ⇒ Object
Check environment for current run state.
-
#environment ⇒ Object
Environment read attribute, detects current environment if not already set.
-
#environment=(val) ⇒ Object
Environment write attribute.
Instance Method Details
#assert_environment ⇒ Object
Throw an exception if the environment is not valid.
41 42 43 |
# File 'lib/ghaki/env/engine.rb', line 41 def assert_environment _assert_environment( @environment ) end |
#clear_environment ⇒ Object
Clears current set environment.
35 36 37 |
# File 'lib/ghaki/env/engine.rb', line 35 def clear_environment @environment = nil end |
#detect_environment ⇒ Object
Check environment for current run state.
47 48 49 |
# File 'lib/ghaki/env/engine.rb', line 47 def detect_environment _assert_environment( self._detect_environment ) end |
#environment ⇒ Object
Environment read attribute, detects current environment if not already set.
23 24 25 |
# File 'lib/ghaki/env/engine.rb', line 23 def environment @environment ||= self.detect_environment end |
#environment=(val) ⇒ Object
Environment write attribute. Asserts on acceptable values.
29 30 31 |
# File 'lib/ghaki/env/engine.rb', line 29 def environment= val @environment = _assert_environment( val ) end |