Sha256: 5efbfaba84117619765af89520a498eefbcd9c940c35bb91e832d27b4a27abec

Contents?: true

Size: 1005 Bytes

Versions: 8

Compression:

Stored size: 1005 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.11.0.beta9 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta8 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta7 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta6 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta5 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta4 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta3 lib/flipper/adapters/read_only.rb
flipper-0.11.0.beta1 lib/flipper/adapters/read_only.rb