Class: Flipper::Adapters::OperationLogger
Overview
Public: Adapter that wraps another adapter and stores the operations.
Useful in tests to verify calls and such. Never use outside of testing.
Defined Under Namespace
Classes: Operation
Constant Summary collapse
- OperationTypes =
[ :features, :add, :remove, :clear, :get, :enable, :disable, ]
Instance Attribute Summary collapse
-
#operations ⇒ Object
readonly
Internal: An array of the operations that have happened.
Instance Method Summary collapse
-
#count(type) ⇒ Object
Public: Count the number of times a certain operation happened.
-
#initialize(adapter, operations = nil) ⇒ OperationLogger
constructor
Public.
-
#reset ⇒ Object
Public: Resets the operation log to empty.
Constructor Details
#initialize(adapter, operations = nil) ⇒ OperationLogger
Public
25 26 27 28 |
# File 'lib/flipper/adapters/operation_logger.rb', line 25 def initialize(adapter, operations = nil) super(adapter) @operations = operations || [] end |
Instance Attribute Details
#operations ⇒ Object (readonly)
Internal: An array of the operations that have happened.
22 23 24 |
# File 'lib/flipper/adapters/operation_logger.rb', line 22 def operations @operations end |
Instance Method Details
#count(type) ⇒ Object
Public: Count the number of times a certain operation happened.
41 42 43 |
# File 'lib/flipper/adapters/operation_logger.rb', line 41 def count(type) @operations.select { |operation| operation.type == type }.size end |
#reset ⇒ Object
Public: Resets the operation log to empty
46 47 48 |
# File 'lib/flipper/adapters/operation_logger.rb', line 46 def reset @operations.clear end |