Updating documentation on FeatureFlag.accessible? (#15492)
* Updating documentation on FeatureFlag.accessible? Related to clarifying behavior for #15475 * Update app/services/feature_flag.rb Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
This commit is contained in:
parent
a3441a318d
commit
1a249dd208
1 changed files with 23 additions and 1 deletions
|
|
@ -1,9 +1,31 @@
|
||||||
|
# This module provides mechanisms for toggling on and off features.
|
||||||
|
#
|
||||||
|
# @note A wrapper around the Flipper gem
|
||||||
module FeatureFlag
|
module FeatureFlag
|
||||||
class << self
|
class << self
|
||||||
delegate :add, :disable, :enable, :enabled?, :exist?, :remove, to: Flipper
|
delegate :add, :disable, :enable, :enabled?, :exist?, :remove, to: Flipper
|
||||||
|
|
||||||
|
# Unless the given :feature_flag_name is _explicitly_ disabled,
|
||||||
|
# this method returns true.
|
||||||
|
#
|
||||||
|
# @param feature_flag_name [Symbol]
|
||||||
|
# @param args [Array] passed to FeatureFlag.enabled?
|
||||||
|
#
|
||||||
|
# @return [TrueClass] go ahead and use this feature
|
||||||
|
# @return [FalseClass] don't use this feature
|
||||||
|
#
|
||||||
|
# @note This is an optimistic test, namely if the given
|
||||||
|
# :feature_flag_name does not exist (e.g., has never been
|
||||||
|
# enabled, disabled, or has been removed), the feature is
|
||||||
|
# accessible.
|
||||||
|
#
|
||||||
|
# @see https://github.com/forem/forem/pull/8149
|
||||||
|
# for further discussion.
|
||||||
def accessible?(feature_flag_name, *args)
|
def accessible?(feature_flag_name, *args)
|
||||||
feature_flag_name.blank? || !exist?(feature_flag_name) || enabled?(feature_flag_name, *args)
|
return true if feature_flag_name.blank?
|
||||||
|
return true unless exist?(feature_flag_name)
|
||||||
|
|
||||||
|
enabled?(feature_flag_name, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue