method
unify_key
ruby latest stable - Class:
JSON::Editor::JSONTreeView
unify_key(iter, key)private
No documentation available.
# File ext/json/lib/json/editor.rb, line 742
def unify_key(iter, key)
return unless iter.type == 'Key'
parent = iter.parent
if parent.any? { |c| c != iter and c.content == key }
old_key = key
i = 0
begin
key = sprintf("%s.%d", old_key, i += 1)
end while parent.any? { |c| c != iter and c.content == key }
end
iter.content = key
end