Permalink
Browse files

Added remove and clear to operation logger adapter.

  • Loading branch information...
jnunemaker committed Feb 20, 2013
1 parent 3cfb49b commit 72b52ff664bc094583472350715cf552ddcd2a11
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/flipper/adapters/operation_logger.rb
@@ -9,11 +9,13 @@ class OperationLogger < Decorator
Operation = Struct.new(:type, :args)
OperationTypes = [
- :get,
+ :features,
:add,
+ :remove,
+ :clear,
+ :get,
:enable,
:disable,
- :features
]
# Internal: An array of the operations that have happened.
@@ -25,6 +27,7 @@ def initialize(adapter, operations = nil)
@operations = operations || []
end
+ # Wraps original method with in memory log of operations performed.
OperationTypes.each do |type|
class_eval <<-EOE
def #{type}(*args)
@@ -36,9 +39,7 @@ def #{type}(*args)
# Public: Count the number of times a certain operation happened.
def count(type)
- @operations.select { |operation|
- operation.type == type
- }.size
+ @operations.select { |operation| operation.type == type }.size
end
# Public: Resets the operation log to empty

0 comments on commit 72b52ff

Please sign in to comment.