gitlab-org--gitlab-foss/lib/gitlab/usage/metrics/key_path_processor.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
486 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
class KeyPathProcessor
class << self
def process(key_path, value)
unflatten(key_path.split('.'), value)
end
private
def unflatten(keys, value)
loop do
value = { keys.pop.to_sym => value }
break if keys.blank?
end
value
end
end
end
end
end
end