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:
Jeremy Friesen 2021-11-29 20:25:17 -05:00 committed by GitHub
parent a3441a318d
commit 1a249dd208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,31 @@
# This module provides mechanisms for toggling on and off features.
#
# @note A wrapper around the Flipper gem
module FeatureFlag
class << self
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)
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