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:
authorToon Claes <toon@gitlab.com>2017-03-01 23:23:00 +0300
committerToon Claes <toon@gitlab.com>2017-03-02 14:15:25 +0300
commita3fdd6acd27f5aa98f13e7a0083d0c3208003ccb (patch)
treee174834a5aaf50b0444f829e8a2cfd678e833455 /lib/gitlab/visibility_level.rb
parentbc20fa9b02d5fea8f5781b6397af10f006983111 (diff)
Use string based `visibility` getter & setter
Add `visibility` & `visibility=` methods to the `Gitlab::VisibilityLevel` module so the `visibility_level` can be get/set with a string value.
Diffstat (limited to 'lib/gitlab/visibility_level.rb')
-rw-r--r--lib/gitlab/visibility_level.rb23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index a3047533ea9..2248763c106 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -95,21 +95,38 @@ module Gitlab
level_name
end
+ def level_value(level)
+ return string_options[level] if level.is_a? String
+ level
+ end
+
def string_level(level)
string_options.key(level)
end
end
def private?
- visibility_level_field == PRIVATE
+ visibility_level_value == PRIVATE
end
def internal?
- visibility_level_field == INTERNAL
+ visibility_level_value == INTERNAL
end
def public?
- visibility_level_field == PUBLIC
+ visibility_level_value == PUBLIC
+ end
+
+ def visibility_level_value
+ self[visibility_level_field]
+ end
+
+ def visibility
+ Gitlab::VisibilityLevel.string_level(visibility_level_value)
+ end
+
+ def visibility=(level)
+ self[visibility_level_field] = Gitlab::VisibilityLevel.level_value(level)
end
end
end