summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-02-16 11:06:40 +0100
committerToon Claes <toon@gitlab.com>2017-03-02 09:28:41 +0100
commitfc287191451bb6aac80d759ab521b5834d27df43 (patch)
treebfbad51bfe8d7ffc175c8afb13d7a63ad31773fd
parent3b3f0fab452fb9cbe4fbe7f75112bef3a7f9d039 (diff)
downloadgitlab-ce-fc287191451bb6aac80d759ab521b5834d27df43.tar.gz
A VisibilityLevel also can be presented as string
For the API, the VisibilityLevel will be exposed as String instead of Integer. So add the string values and method to translate a level integer to a string.
-rw-r--r--lib/gitlab/visibility_level.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index b28708c34e1..a3047533ea9 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -35,6 +35,10 @@ module Gitlab
class << self
delegate :values, to: :options
+ def string_values
+ string_options.keys
+ end
+
def options
{
'Private' => PRIVATE,
@@ -43,6 +47,14 @@ module Gitlab
}
end
+ def string_options
+ {
+ 'private' => PRIVATE,
+ 'internal' => INTERNAL,
+ 'public' => PUBLIC
+ }
+ end
+
def highest_allowed_level
restricted_levels = current_application_settings.restricted_visibility_levels
@@ -82,6 +94,10 @@ module Gitlab
level_name
end
+
+ def string_level(level)
+ string_options.key(level)
+ end
end
def private?