Skip to content

Commit

Permalink
deep_merge -> deep_sync, thanks @tmsrjs
Browse files Browse the repository at this point in the history
  • Loading branch information
nofxx committed Dec 12, 2014
1 parent 640ec49 commit 90c2f93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/sync.rb
Expand Up @@ -51,7 +51,7 @@ def sync
out "Writing #{filename}"
(_comments, old) = read_file(filename, lang)
# Initializing hash variable as empty if it does not exist
other = @words.dup.deep_merge! old
other = @words.dup.deep_sync! old
write_file(filename, lang, @comments, other)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/sync/hash.rb
@@ -1,10 +1,10 @@
class Hash

# Ensures multilevel hash merging
def deep_merge!(other_hash)
other_hash.each do |k,v|
def deep_sync!(other_hash)
other_hash.each do |k, v|
next unless tv = self[k]
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.dup.deep_merge!(v) : v
self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.dup.deep_sync!(v) : v
end
self
end
Expand Down

0 comments on commit 90c2f93

Please sign in to comment.