Files
grecia/app/controllers/concerns/feature_flags.rb
Javi Martín fdfdbcbd0d Add and apply Style/ArgumentsForwarding rule
We were using generic names like `args` and `options` which don't really
add anything to `*` or `**` because Ruby required us to.

That's no longer the case in Ruby 3.2, so we can simplify the code a
bit.
2024-04-11 17:59:40 +02:00

26 lines
478 B
Ruby

module FeatureFlags
extend ActiveSupport::Concern
class_methods do
def feature_flag(name, *)
before_action(*) do
check_feature_flag(name)
end
end
end
def check_feature_flag(name)
raise FeatureDisabled, name unless Setting["feature.#{name}"] || Setting["process.#{name}"]
end
class FeatureDisabled < Exception
def initialize(name)
@name = name
end
def message
"Feature disabled: #{@name}"
end
end
end