Sha256: 52382c9ce448843c57179d5efcd1a042c03e4f92f2a88955b9666d660da8d91e

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

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

      # Public: The name of the adapter.
      attr_reader :name

      # 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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flipper-0.25.4 lib/flipper/adapters/dual_write.rb
flipper-0.25.3 lib/flipper/adapters/dual_write.rb
flipper-0.25.2 lib/flipper/adapters/dual_write.rb
flipper-0.25.1 lib/flipper/adapters/dual_write.rb
flipper-0.25.0 lib/flipper/adapters/dual_write.rb
flipper-0.24.1 lib/flipper/adapters/dual_write.rb
flipper-0.24.0 lib/flipper/adapters/dual_write.rb
flipper-0.23.1 lib/flipper/adapters/dual_write.rb
flipper-0.23.0 lib/flipper/adapters/dual_write.rb