Class: FeatureFlagger::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_flagger/manager.rb

Class Method Summary collapse

Class Method Details

.cleanup_detached(resource_name, *feature_key) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/feature_flagger/manager.rb', line 19

def self.cleanup_detached(resource_name, *feature_key)
  feature = Feature.new(feature_key, resource_name)
  raise 'key is still mapped'
rescue FeatureFlagger::KeyNotFoundError => _e
  # This means the keys is not present in config file anymore
  key_resolver = KeyResolver.new(feature_key, resource_name)
  FeatureFlagger.control.unrelease_to_all(key_resolver.normalized_key, resource_name)
end

.detached_feature_keys(resource_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/feature_flagger/manager.rb', line 5

def self.detached_feature_keys(resource_name)
  keys = FeatureFlagger.control.search_keys("#{resource_name}:*")

  persisted_features = keys.flat_map do |key|
    FeatureFlagger.control.all_feature_keys(resource_name, key.sub("#{resource_name}:", ''))
  end.sort.uniq

  mapped_feature_keys = FeatureFlagger.config.mapped_feature_keys(resource_name).map do |feature|
    feature.sub("#{resource_name}:", '')
  end

  persisted_features - mapped_feature_keys
end