1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/haml/util.rb
nex3 1f112ca018 Forgot to add a whole bunch of files.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@451 7063305b-7217-0410-af8c-cdc13e5119b9
2007-03-25 19:07:16 +00:00

20 lines
500 B
Ruby

# This file contains various useful bits of code
# that are shared between Haml and Sass.
class Hash # :nodoc:
# Same as Hash#merge!,
# but recursively merges sub-hashes and arrays
def rec_merge!(other)
other.each do |key, value|
myval = self[key]
if value.is_a?(Hash) && myval.is_a?(Hash)
myval.rec_merge!(value)
elsif value.is_a?(Array) && myval.is_a?(Array)
myval.concat(value)
else
self[key] = value
end
end
self
end
end