Files
openfoodnetwork/app/constraints/feature_toggle_constraint.rb
Maikel Linke 81461684f3 Generalise feature toggle constraint
Now we can re-use it for any feature.
2022-10-13 10:42:20 +11:00

16 lines
304 B
Ruby

# frozen_string_literal: true
class FeatureToggleConstraint
def initialize(feature_name)
@feature = feature_name
end
def matches?(request)
OpenFoodNetwork::FeatureToggle.enabled?(@feature, current_user(request))
end
def current_user(request)
request.env['warden'].user
end
end