1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
module Flipper
module Adapters
class DualWrite
include ::Flipper::Adapter
# Public: The name of the adapter.
attr_reader :name, :local, :remote
# Public: Build a new sync instance.
#
# local - The local flipper adapter that should serve reads.
# remote - The remote flipper adapter that writes should go to first (in
# addition to the local adapter).
def initialize(local, remote, options = {})
@name = :dual_write
@local = local
@remote = remote
end
def features
@local.features
end
def get(feature)
@local.get(feature)
end
def get_multi(features)
@local.get_multi(features)
end
def get_all
@local.get_all
end
def add(feature)
@remote.add(feature).tap { @local.add(feature) }
end
def remove(feature)
@remote.remove(feature).tap { @local.remove(feature) }
end
def clear(feature)
@remote.clear(feature).tap { @local.clear(feature) }
end
def enable(feature, gate, thing)
@remote.enable(feature, gate, thing).tap do
@local.enable(feature, gate, thing)
end
end
def disable(feature, gate, thing)
@remote.disable(feature, gate, thing).tap do
@local.disable(feature, gate, thing)
end
end
end
end
end
|