Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 06:06:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-23 06:06:01 +0300
commit8c7eab92cd0009f55cb999bbade43e0f969c137e (patch)
tree180cac6632448a211ddbe555191574c98e8dc385 /lib/gitlab/utils.rb
parentdffeff5520e861dc6e7319b690c573186bbbd22e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/utils.rb')
-rw-r--r--lib/gitlab/utils.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index 7fbfc4c45c4..5cba6c52773 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -130,5 +130,15 @@ module Gitlab
IPAddr.new(str)
rescue IPAddr::InvalidAddressError
end
+
+ # Filter a Hash against a mapping of keys to sets of allowed values.
+ #
+ # Keys that do not pass the filter will be removed from the Hash.
+ # This mutates the input hash.
+ def allow_hash_values(hash, allowed)
+ allowed.each do |key, allowed_values|
+ hash.delete(key) if hash.key?(key) && !allowed_values.include?(hash[key])
+ end
+ end
end
end