Class: AIPP::Environment
- Inherits:
-
Object
- Object
- AIPP::Environment
- Includes:
- Singleton
- Defined in:
- lib/aipp/environment.rb
Overview
Runtime environment
Runtime environment objects inherit from OpenStruct but feature some extensions:
-
Use
replace
to replace the current key/value table with the given hash. -
Use
merge
to merge the given hash into the current key/value hash. -
When reading a value using square brackets, the key is implicitly converted to Symbol.
Defined Under Namespace
Classes: Borders, Cache, Config, Fixtures, Options
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
75 76 77 78 79 80 81 82 83 |
# File 'lib/aipp/environment.rb', line 75 def initialize [Cache, Borders, Fixtures, Options, Config].each do |klass| attribute = klass.to_s.split('::').last.downcase instance_variable_set("@#{attribute}", klass.new) AIPP.define_singleton_method(attribute) do Environment.instance.instance_variable_get "@#{attribute}" end end end |