class FeatureFlagger::Control
Constants
- RELEASED_FEATURES
Attributes
storage[R]
Public Class Methods
new(storage, notifier, cache_store = nil)
click to toggle source
# File lib/feature_flagger/control.rb, line 7 def initialize(storage, notifier, cache_store = nil) @storage = storage @notifier = notifier @cache_store = cache_store end
Public Instance Methods
cache(name, options, &block)
click to toggle source
# File lib/feature_flagger/control.rb, line 80 def cache(name, options, &block) if @cache_store @cache_store.fetch(name, force: options[:skip_cache]) do block.call end else block.call end end
feature_keys()
click to toggle source
# File lib/feature_flagger/control.rb, line 76 def feature_keys @storage.feature_keys - [FeatureFlagger::Control::RELEASED_FEATURES] end
release(feature_key, resource_id)
click to toggle source
# File lib/feature_flagger/control.rb, line 19 def release(feature_key, resource_id) resource_name = Storage::Keys.extract_resource_name_from_feature_key( feature_key ) @notifier.send(FeatureFlagger::Notifier::RELEASE, feature_key, resource_id) @storage.add(feature_key, resource_name, resource_id) end
release_to_all(feature_key)
click to toggle source
# File lib/feature_flagger/control.rb, line 34 def release_to_all(feature_key) @notifier.send(FeatureFlagger::Notifier::RELEASE_TO_ALL, feature_key) @storage.add_all(RELEASED_FEATURES, feature_key) end
released?(feature_key, resource_id, options = {})
click to toggle source
# File lib/feature_flagger/control.rb, line 13 def released?(feature_key, resource_id, options = {}) cache "released/#{feature_key}/#{resource_id}", options do @storage.has_value?(RELEASED_FEATURES, feature_key) || @storage.has_value?(feature_key, resource_id) end end
released_features_to_all(options = {})
click to toggle source
# File lib/feature_flagger/control.rb, line 58 def released_features_to_all(options = {}) cache "released_features_to_all/#{RELEASED_FEATURES}", options do @storage.all_values(RELEASED_FEATURES) end end
released_to_all?(feature_key, options = {})
click to toggle source
# File lib/feature_flagger/control.rb, line 64 def released_to_all?(feature_key, options = {}) cache "has_value/#{RELEASED_FEATURES}/#{feature_key}", options do @storage.has_value?(RELEASED_FEATURES, feature_key) end end
releases(resource_name, resource_id, options = {})
click to toggle source
# File lib/feature_flagger/control.rb, line 28 def releases(resource_name, resource_id, options = {}) cache "releases/#{resource_name}/#{resource_id}", options do @storage.fetch_releases(resource_name, resource_id, RELEASED_FEATURES) end end
resource_ids(feature_key, options = {})
click to toggle source
# File lib/feature_flagger/control.rb, line 52 def resource_ids(feature_key, options = {}) cache "all_values/#{feature_key}", options do @storage.all_values(feature_key) end end
search_keys(query)
click to toggle source
DEPRECATED: this method will be removed from public api on v2.0 version. use instead the feature_keys
method.
# File lib/feature_flagger/control.rb, line 72 def search_keys(query) @storage.search_keys(query) end
unrelease(feature_key, resource_id)
click to toggle source
# File lib/feature_flagger/control.rb, line 39 def unrelease(feature_key, resource_id) resource_name = Storage::Keys.extract_resource_name_from_feature_key( feature_key ) @notifier.send(FeatureFlagger::Notifier::UNRELEASE, feature_key, resource_id) @storage.remove(feature_key, resource_name, resource_id) end
unrelease_to_all(feature_key)
click to toggle source
# File lib/feature_flagger/control.rb, line 47 def unrelease_to_all(feature_key) @notifier.send(FeatureFlagger::Notifier::UNRELEASE_TO_ALL, feature_key) @storage.remove_all(RELEASED_FEATURES, feature_key) end