Class: Wright::Config
- Inherits:
-
Object
- Object
- Wright::Config
- Extended by:
- Forwardable
- Defined in:
- lib/wright/config.rb
Overview
Configuration container, wraps a regular Ruby hash.
Useful for getting and setting configuration values, such as logging verbosity, color output and provider configuration.
Class Method Summary collapse
-
.nested_key?(*path) ⇒ Bool
Checks if a (nested) configuration value is set.
-
.nested_value(*path) ⇒ Object
Retrieves a (nested) configuration value.
Class Method Details
.nested_key?(*path) ⇒ Bool
Checks if a (nested) configuration value is set.
35 36 37 38 39 40 41 42 |
# File 'lib/wright/config.rb', line 35 def self.nested_key?(*path) last_key = path.pop last_hash = path.reduce(@config_hash) do |hash, key| return false unless hash.respond_to?(:fetch) hash.fetch(key, {}) end last_hash.respond_to?(:key?) && last_hash.key?(last_key) end |
.nested_value(*path) ⇒ Object
Retrieves a (nested) configuration value.
57 58 59 |
# File 'lib/wright/config.rb', line 57 def self.nested_value(*path) nested_key?(*path) ? path.reduce(@config_hash) { |a, e| a[e] } : nil end |