1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
require 'flipper'
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
|