summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-21 16:49:51 +0200
committerRémy Coutable <remy@rymai.me>2017-06-27 18:59:51 +0200
commitb4d325c80c63ee9ee2676a57a42fac472b5b20d5 (patch)
tree15e4dea85ab1ae5538ffe35d0c9b0ee2dbfcaadc /app
parentcc50decab5b22628eafb6636b3e57f99094c7926 (diff)
downloadgitlab-ce-b4d325c80c63ee9ee2676a57a42fac472b5b20d5.tar.gz
Allow the feature flags to be enabled/disabled with more granularity
This allows to enable/disable a feature flag for a given user, or a given Flipper group (must be declared statically in the `flipper.rb` initializer beforehand). Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app')
-rw-r--r--app/models/concerns/flippable.rb7
-rw-r--r--app/models/user.rb1
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/concerns/flippable.rb b/app/models/concerns/flippable.rb
new file mode 100644
index 00000000000..341501e8250
--- /dev/null
+++ b/app/models/concerns/flippable.rb
@@ -0,0 +1,7 @@
+module Flippable
+ def flipper_id
+ return nil if new_record?
+
+ "#{self.class.name}:#{id}"
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 6dd1b1415d6..bcce260ab08 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -11,6 +11,7 @@ class User < ActiveRecord::Base
include CaseSensitivity
include TokenAuthenticatable
include IgnorableColumn
+ include Flippable
DEFAULT_NOTIFICATION_LEVEL = :participating