Class: Toggleable::FeatureToggler

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/toggleable/feature_toggler.rb

Overview

Toggleable::FeatureToggler provides an instance to manage all toggleable keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFeatureToggler

Returns a new instance of FeatureToggler.



12
13
14
# File 'lib/toggleable/feature_toggler.rb', line 12

def initialize
  @features = []
end

Instance Attribute Details

#featuresObject (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