Custom adapter raising "undefined method `memoize='" #555
-
Hello! I'm trying to add feature flagging for a method that generates and caches some Javascript. To make the flag work, I need to rebuild the cache. I've created an adapter like so: require 'flipper'
class CacheBuster < SimpleDelegator
include ::Flipper::Adapter
attr_reader :name
def initialize(adapter)
@adapter = adapter
@name = :cache_buster
end
def enable(feature, gate, thing)
@adapter.enable(feature, gate, thing)
rebuild_cache(thing)
end
def disable(feature, gate, thing)
@adapter.disable(feature, gate, thing)
rebuild_cache(thing)
end
private
def rebuild_cache(thing)
# Call the cache rebuild here.
end
end And I'm setting it up like this: require 'flipper'
require 'flipper/adapters/redis'
require_relative '../../lib/cache_buster'
Flipper.configure do |config|
config.default do
CacheBuster.new(Flipper::Adapters::Redis.new($redis))
end
end But when I run my app, I get the following exception:
I'm confused. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Nevermind, I overlooked the fact that you need to actually create an instance of Flipper in the configure block. Flipper.configure do |config|
config.default do
adapter = CacheBuster.new(Flipper::Adapters::Redis.new($redis))
Flipper.new(adapter)
end
end Also need to define the methods passed through to the Redis class. 🤦♂️ |
Beta Was this translation helpful? Give feedback.
Nevermind, I overlooked the fact that you need to actually create an instance of Flipper in the configure block.
Also need to define the methods passed through to the Redis class. 🤦♂️