Feature-flag debates

This commit is contained in:
Josep Jaume Rey Peroy
2016-01-18 11:24:22 +01:00
parent 91d583c8b2
commit 2d45828cad
14 changed files with 85 additions and 14 deletions

View 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