Class: BarsoomUtils::FeatureToggle
- Inherits:
-
Object
- Object
- BarsoomUtils::FeatureToggle
- Defined in:
- lib/barsoom_utils/feature_toggle.rb
Constant Summary collapse
- REDIS_KEY =
We (counter-intuitively, perhaps) store disabled toggles, so we can assume them to be enabled by default in dev, staging and tests.
"disabled_feature_toggles"
Class Method Summary collapse
- .list ⇒ Object
- .off?(feature, controller_or_view = nil, redis: self.redis) ⇒ Boolean
- .on?(feature, controller_or_view = nil, redis: self.redis) ⇒ Boolean
- .redis ⇒ Object
- .redis=(redis) ⇒ Object
- .turn_off(feature, redis: self.redis) ⇒ Object
- .turn_on(feature, redis: self.redis) ⇒ Object
Instance Method Summary collapse
Class Method Details
.list ⇒ Object
34 35 36 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 34 def self.list redis.smembers(REDIS_KEY).sort end |
.off?(feature, controller_or_view = nil, redis: self.redis) ⇒ Boolean
22 23 24 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 22 def self.off?(feature, controller_or_view = nil, redis: self.redis) new(feature, controller_or_view: controller_or_view, redis: redis).off? end |
.on?(feature, controller_or_view = nil, redis: self.redis) ⇒ Boolean
18 19 20 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 18 def self.on?(feature, controller_or_view = nil, redis: self.redis) new(feature, controller_or_view: controller_or_view, redis: redis).on? end |
.redis ⇒ Object
14 15 16 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 14 def self.redis @redis || $redis end |
.redis=(redis) ⇒ Object
10 11 12 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 10 def self.redis=(redis) @redis = redis end |
.turn_off(feature, redis: self.redis) ⇒ Object
30 31 32 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 30 def self.turn_off(feature, redis: self.redis) new(feature, redis: redis).turn_off end |
.turn_on(feature, redis: self.redis) ⇒ Object
26 27 28 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 26 def self.turn_on(feature, redis: self.redis) new(feature, redis: redis).turn_on end |
Instance Method Details
#off? ⇒ Boolean
48 49 50 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 48 def off? not on? end |
#on? ⇒ Boolean
40 41 42 43 44 45 46 |
# File 'lib/barsoom_utils/feature_toggle.rb', line 40 def on? if has_param_override? on_according_to_param? else on_according_to_redis? end end |