lib/flipper/adapters/operation_logger.rb in flipper-0.26.2 vs lib/flipper/adapters/operation_logger.rb in flipper-0.27.0
- old
+ new
@@ -3,12 +3,12 @@
module Flipper
module Adapters
# Public: Adapter that wraps another adapter and stores the operations.
#
# Useful in tests to verify calls and such. Never use outside of testing.
- class OperationLogger < SimpleDelegator
- include ::Flipper::Adapter
+ class OperationLogger
+ include Flipper::Adapter
class Operation
attr_reader :type, :args
def initialize(type, args)
@@ -16,10 +16,12 @@
@args = args
end
end
OperationTypes = [
+ :import,
+ :export,
:features,
:add,
:remove,
:clear,
:get,
@@ -35,11 +37,10 @@
# Internal: The name of the adapter.
attr_reader :name
# Public
def initialize(adapter, operations = nil)
- super(adapter)
@adapter = adapter
@name = :operation_logger
@operations = operations || []
end
@@ -94,9 +95,21 @@
# Public
def disable(feature, gate, thing)
@operations << Operation.new(:disable, [feature, gate, thing])
@adapter.disable(feature, gate, thing)
+ end
+
+ # Public
+ def import(source)
+ @operations << Operation.new(:import, [source])
+ @adapter.import(source)
+ end
+
+ # Public
+ def export(format: :json, version: 1)
+ @operations << Operation.new(:export, [format, version])
+ @adapter.export(format: format, version: version)
end
# Public: Count the number of times a certain operation happened.
def count(type)
type(type).size