Sha256: bab6e30560a794351cbe6aae642ee14c29be65ab93a67a947461c39ae998dd44

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

module Flipper
  module Adapters
    class DualWrite
      include ::Flipper::Adapter

      attr_reader :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 = {})
        @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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/adapters/dual_write.rb
flipper-1.3.1 lib/flipper/adapters/dual_write.rb
flipper-1.3.0 lib/flipper/adapters/dual_write.rb
flipper-1.3.0.pre lib/flipper/adapters/dual_write.rb
flipper-1.2.2 lib/flipper/adapters/dual_write.rb
flipper-1.2.1 lib/flipper/adapters/dual_write.rb
flipper-1.2.0 lib/flipper/adapters/dual_write.rb
flipper-1.1.2 lib/flipper/adapters/dual_write.rb
flipper-1.1.1 lib/flipper/adapters/dual_write.rb
flipper-1.1.0 lib/flipper/adapters/dual_write.rb