Class: RubyPitaya::Config
- Inherits:
-
Object
- Object
- RubyPitaya::Config
- Defined in:
- lib/rubypitaya/core/config.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #auto_reload ⇒ Object
- #clear_cache ⇒ Object
- #config_core_override=(value) ⇒ Object
- #fetch(*args) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubypitaya/core/config.rb', line 8 def initialize @config_core = ConfigCore.new @config_core_override = nil @has_config_core_override = false @empty_hash = {} @result_cache = {} @empty_hash.extend(ConfigHashExtension) @result_cache.extend(ConfigHashExtension) end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubypitaya/core/config.rb', line 20 def [](key) result = @result_cache[key] return result unless result.nil? if @has_config_core_override result = @config_core_override[key] result = @config_core[key] if result.nil? else result = @config_core[key] end @result_cache[key] = result result end |
#auto_reload ⇒ Object
43 44 45 46 |
# File 'lib/rubypitaya/core/config.rb', line 43 def auto_reload @config_core.auto_reload @config_core_override.auto_reload unless @config_core_override.nil? end |
#clear_cache ⇒ Object
48 49 50 |
# File 'lib/rubypitaya/core/config.rb', line 48 def clear_cache @result_cache.clear end |
#config_core_override=(value) ⇒ Object
52 53 54 55 |
# File 'lib/rubypitaya/core/config.rb', line 52 def config_core_override=(value) @config_core_override = value @has_config_core_override = !value.nil? end |
#fetch(*args) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rubypitaya/core/config.rb', line 36 def fetch(*args) result = self[args[0]] return result unless result.nil? @empty_hash.fetch(*args) end |