Feature-flag debates
This commit is contained in:
25
app/controllers/concerns/feature_flags.rb
Normal file
25
app/controllers/concerns/feature_flags.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
module FeatureFlags
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def feature_flag(name, *options)
|
||||
before_filter(*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
|
||||
Reference in New Issue
Block a user