Sha256: d86e6244f0d1c1141d73aa9de74ab6c223af2bfd174356ec26cb443c4659fa0d

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

module Flipper
  module Adapters
    # Public: Adapter that wraps another adapter and raises for any writes.
    class ReadOnly
      include ::Flipper::Adapter

      class WriteAttempted < Error
        def initialize(message = nil)
          super(message || 'write attempted while in read only mode')
        end
      end

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

      # Public
      def initialize(adapter)
        @adapter = adapter
        @name = :read_only
      end

      def features
        @adapter.features
      end

      def get(feature)
        @adapter.get(feature)
      end

      def get_multi(features)
        @adapter.get_multi(features)
      end

      def get_all
        @adapter.get_all
      end

      def add(_feature)
        raise WriteAttempted
      end

      def remove(_feature)
        raise WriteAttempted
      end

      def clear(_feature)
        raise WriteAttempted
      end

      def enable(_feature, _gate, _thing)
        raise WriteAttempted
      end

      def disable(_feature, _gate, _thing)
        raise WriteAttempted
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flipper-0.15.0 lib/flipper/adapters/read_only.rb
flipper-0.14.0 lib/flipper/adapters/read_only.rb
flipper-0.13.0 lib/flipper/adapters/read_only.rb
flipper-0.13.0.beta1 lib/flipper/adapters/read_only.rb
flipper-0.12.2 lib/flipper/adapters/read_only.rb
flipper-0.12.1 lib/flipper/adapters/read_only.rb
flipper-0.12.0 lib/flipper/adapters/read_only.rb
flipper-0.11.0 lib/flipper/adapters/read_only.rb
flipper-0.11.0.rc1 lib/flipper/adapters/read_only.rb