diff options
Diffstat (limited to 'lib/feature/active_support_cache_store_adapter.rb')
-rw-r--r-- | lib/feature/active_support_cache_store_adapter.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/feature/active_support_cache_store_adapter.rb b/lib/feature/active_support_cache_store_adapter.rb new file mode 100644 index 00000000000..ae2d623abe1 --- /dev/null +++ b/lib/feature/active_support_cache_store_adapter.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# rubocop:disable Gitlab/NamespacedClass +# This class was already nested this way before moving to a separate file +class Feature + class ActiveSupportCacheStoreAdapter < Flipper::Adapters::ActiveSupportCacheStore + def enable(feature, gate, thing) + result = @adapter.enable(feature, gate, thing) + @cache.write(key_for(feature.key), @adapter.get(feature), @write_options) + result + end + + def disable(feature, gate, thing) + result = @adapter.disable(feature, gate, thing) + @cache.write(key_for(feature.key), @adapter.get(feature), @write_options) + result + end + + def remove(feature) + result = @adapter.remove(feature) + @cache.delete(FeaturesKey) + @cache.write(key_for(feature.key), {}, @write_options) + result + end + end +end +# rubocop:disable Gitlab/NamespacedClass |