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
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-09-06 11:22:19 +0300
committerSean McGivern <sean@mcgivern.me.uk>2018-09-06 11:22:19 +0300
commit26de39fc64e927378e839ec1037f655bf87e3e73 (patch)
tree152ce52b29cfe475cab3c1692289b4dd67fa693e /lib
parent3ff54a959d631740f9ad31727048cb175f700c8b (diff)
parente57d99947a8837ef3bfe20022f4c5b3ad735ec8f (diff)
Merge branch 'bw-commonmark-for-files' into 'master'
Enable CommonMark for files and wikis See merge request gitlab-org/gitlab-ce!21228
Diffstat (limited to 'lib')
-rw-r--r--lib/feature.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/feature.rb b/lib/feature.rb
index 24dbcb32fc0..f4b57376313 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -42,13 +42,21 @@ class Feature
persisted_names.include?(feature.name.to_s)
end
- def enabled?(key, thing = nil)
- get(key).enabled?(thing)
+ # use `default_enabled: true` to default the flag to being `enabled`
+ # unless set explicitly. The default is `disabled`
+ def enabled?(key, thing = nil, default_enabled: false)
+ feature = Feature.get(key)
+
+ # If we're not default enabling the flag or the feature has been set, always evaluate.
+ # `persisted?` can potentially generate DB queries and also checks for inclusion
+ # in an array of feature names (177 at last count), possibly reducing performance by half.
+ # So we only perform the `persisted` check if `default_enabled: true`
+ !default_enabled || Feature.persisted?(feature) ? feature.enabled?(thing) : true
end
- def disabled?(key, thing = nil)
+ def disabled?(key, thing = nil, default_enabled: false)
# we need to make different method calls to make it easy to mock / define expectations in test mode
- thing.nil? ? !enabled?(key) : !enabled?(key, thing)
+ thing.nil? ? !enabled?(key, default_enabled: default_enabled) : !enabled?(key, thing, default_enabled: default_enabled)
end
def enable(key, thing = true)