Method: IniFile#merge!
- Defined in:
- lib/inifile.rb
#merge!(other) ⇒ Object
Public: Merges other_inifile into this inifile, overwriting existing entries. Useful for having a system inifile with user over-ridable settings elsewhere.
other - The other IniFile.
Returns this IniFile.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/inifile.rb', line 192 def merge!( other ) my_keys = @ini.keys other_keys = case other when IniFile; other.instance_variable_get(:@ini).keys when Hash; other.keys else raise "cannot merge contents from '#{other.class.name}'" end (my_keys & other_keys).each do |key| @ini[key].merge!(other[key]) end (other_keys - my_keys).each do |key| @ini[key] = other[key] end self end |