Sha256: e1f4b1859596219c43c98cdb9f5a284ccc374a3c98193bcb9bcde45690c0cb59

Contents?: true

Size: 996 Bytes

Versions: 8

Compression:

Stored size: 996 Bytes

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 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

8 entries across 8 versions & 1 rubygems

Version Path
flipper-0.10.2 lib/flipper/adapters/read_only.rb
flipper-0.10.1 lib/flipper/adapters/read_only.rb
flipper-0.10.0 lib/flipper/adapters/read_only.rb
flipper-0.9.2 lib/flipper/adapters/read_only.rb
flipper-0.9.1 lib/flipper/adapters/read_only.rb
flipper-0.9.0 lib/flipper/adapters/read_only.rb
flipper-0.9.0.beta1 lib/flipper/adapters/read_only.rb
flipper-0.8.0 lib/flipper/adapters/read_only.rb