Files
nairobi/app/controllers/concerns/feature_flags.rb
Juanjo Bazán dc7ee45766 uses before_action instead of before_filter
before_filter is deprecated
2016-07-18 14:50:28 +02:00

26 lines
462 B
Ruby

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