Class: Toggleable::FeatureToggler
- Inherits:
-
Object
- Object
- Toggleable::FeatureToggler
- Includes:
- Singleton
- Defined in:
- lib/toggleable/feature_toggler.rb
Overview
Toggleable::FeatureToggler provides an instance to manage all toggleable keys.
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
Instance Method Summary collapse
- #available_features(memoize: Toggleable.configuration.use_memoization) ⇒ Object
-
#initialize ⇒ FeatureToggler
constructor
A new instance of FeatureToggler.
- #mass_toggle!(mapping, actor: nil) ⇒ Object
- #register(key) ⇒ Object
Constructor Details
#initialize ⇒ FeatureToggler
Returns a new instance of FeatureToggler.
12 13 14 |
# File 'lib/toggleable/feature_toggler.rb', line 12 def initialize @features = [] end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
10 11 12 |
# File 'lib/toggleable/feature_toggler.rb', line 10 def features @features end |
Instance Method Details
#available_features(memoize: Toggleable.configuration.use_memoization) ⇒ Object
20 21 22 23 |
# File 'lib/toggleable/feature_toggler.rb', line 20 def available_features(memoize: Toggleable.configuration.use_memoization) available_features = memoize ? memoized_keys : keys available_features.slice(*features) end |
#mass_toggle!(mapping, actor: nil) ⇒ Object
25 26 27 28 |
# File 'lib/toggleable/feature_toggler.rb', line 25 def mass_toggle!(mapping, actor: nil) log_changes(mapping, actor) if Toggleable.configuration.logger Toggleable.configuration.storage.mass_set(mapping, namespace: Toggleable.configuration.namespace) end |
#register(key) ⇒ Object
16 17 18 |
# File 'lib/toggleable/feature_toggler.rb', line 16 def register(key) features << key end |