Class: TOML::Keygroup

Inherits:
Object
  • Object
show all
Defined in:
lib/toml/keygroup.rb

Instance Method Summary collapse

Constructor Details

#initialize(nested_keys) ⇒ Keygroup

Returns a new instance of Keygroup.



3
4
5
# File 'lib/toml/keygroup.rb', line 3

def initialize(nested_keys)
  @nested_keys = nested_keys
end

Instance Method Details



7
8
9
10
11
12
13
14
15
# File 'lib/toml/keygroup.rb', line 7

def navigate_keys(hash, symbolize_keys = false)
  @nested_keys.each do |key|
    key = symbolize_keys ? key.to_sym : key
    hash[key] = {} unless hash[key]
    hash = hash[key]
  end

  hash
end