Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e57d9994
Commit
e57d9994
authored
Sep 05, 2018
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove guard clause and add comment on performace
parent
c4f26d4b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
lib/feature.rb
lib/feature.rb
+7
-3
No files found.
lib/feature.rb
View file @
e57d9994
...
...
@@ -42,12 +42,16 @@ class Feature
persisted_names
.
include?
(
feature
.
name
.
to_s
)
end
# 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
)
return
feature
.
enabled?
(
thing
)
unless
default_enabled
# If the feature has been set, always evaluate
Feature
.
persisted?
(
feature
)
?
feature
.
enabled?
(
thing
)
:
true
# 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
,
default_enabled:
false
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment