diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-01 09:06:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-01 09:06:13 +0300 |
commit | 1dd77c7113eed7e229e0675ad8742c05cccfd1ee (patch) | |
tree | b924852be9d5ea04bc58ed4af3b467690d167e26 /lib/gitlab | |
parent | ec60358d52be0dc99f52db94dc95209f1486eac9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/utils/inline_hash.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/gitlab/utils/inline_hash.rb b/lib/gitlab/utils/inline_hash.rb index 5985e4da845..41e5f3ee4c3 100644 --- a/lib/gitlab/utils/inline_hash.rb +++ b/lib/gitlab/utils/inline_hash.rb @@ -11,13 +11,15 @@ module Gitlab # # { # 'root_param' => 'Root', + # 12 => 'number', + # symbol: 'symbol', # nested_param: { # key: 'Value' # }, # 'very' => { # 'deep' => { # 'nested' => { - # 'param' => 'Deep nested value' + # 12 => 'Deep nested value' # } # } # } @@ -28,14 +30,21 @@ module Gitlab # # { # 'root_param' => 'Root', + # 12 => 'number', + # symbol: symbol, # 'nested_param.key' => 'Value', - # 'very.deep.nested.param' => 'Deep nested value' + # 'very.deep.nested.12' => 'Deep nested value' # } # def merge_keys(hash, prefix: nil, connector: '.') result = {} - base_prefix = prefix ? "#{prefix}#{connector}" : '' - pairs = hash.map { |key, value| ["#{base_prefix}#{key}", value] } + pairs = + if prefix + base_prefix = "#{prefix}#{connector}" + hash.map { |key, value| ["#{base_prefix}#{key}", value] } + else + hash.to_a + end until pairs.empty? key, value = pairs.shift |