summaryrefslogtreecommitdiff
path: root/lib/feature.rb
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 /lib/feature.rb
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 'lib/feature.rb')
-rw-r--r--lib/feature.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/feature.rb b/lib/feature.rb
index d3d972564af..363f66ba60e 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -12,6 +12,8 @@ class Feature
end
class << self
+ delegate :group, to: :flipper
+
def all
flipper.features.to_a
end
@@ -27,16 +29,24 @@ class Feature
all.map(&:name).include?(feature.name)
end
- def enabled?(key)
- get(key).enabled?
+ def enabled?(key, thing = nil)
+ get(key).enabled?(thing)
+ end
+
+ def enable(key, thing = true)
+ get(key).enable(thing)
+ end
+
+ def disable(key, thing = false)
+ get(key).disable(thing)
end
- def enable(key)
- get(key).enable
+ def enable_group(key, group)
+ get(key).enable_group(group)
end
- def disable(key)
- get(key).disable
+ def disable_group(key, group)
+ get(key).disable_group(group)
end
def flipper