Class: Precursor::ConfigRoot
- Inherits:
-
Object
- Object
- Precursor::ConfigRoot
- Defined in:
- lib/config_root.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(vaults, key_options) ⇒ ConfigRoot
constructor
A new instance of ConfigRoot.
Constructor Details
#initialize(vaults, key_options) ⇒ ConfigRoot
Returns a new instance of ConfigRoot.
5 6 7 8 |
# File 'lib/config_root.rb', line 5 def initialize(vaults, ) @vaults = vaults @key_options = end |
Instance Method Details
#[](key) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/config_root.rb', line 10 def [](key) found = false value = nil @vaults.each do |v| if v.key? key found = true value = v.value key break end end if !found && @key_options.key?(key) && @key_options[key].key?(:default) found = true value = @key_options[key][:default] end raise KeyError, "key #{key} not found" unless found value = resolve_variables(value) if value.is_a? String value end |