lib/tap/support/aggregator.rb in bahuvrihi-tap-0.11.2 vs lib/tap/support/aggregator.rb in bahuvrihi-tap-0.12.0

- old
+ new

@@ -1,21 +1,18 @@ module Tap module Support # Aggregator allows thread-safe collection of Audits, organized - # by Audit#_current_source. + # by Audit#key. # - # a = Audit.new - # a._record(:src, 'a') - # - # b = Audit.new - # b._record(:src, 'b') + # a = Audit.new(:key, 'a') + # b = Audit.new(:key, 'b') # # agg = Aggregator.new # agg.store(a) # agg.store(b) - # agg.retrieve(:src) # => [a, b] + # agg.retrieve(:key) # => [a, b] # class Aggregator < Monitor # Creates a new Aggregator. def initialize @@ -36,12 +33,12 @@ # True if size == 0 def empty? synchronize { hash.empty? } end - # Stores the Audit according to _result._current_source + # Stores the Audit according to _result.key def store(_result) - synchronize { (hash[_result._current_source] ||= []) << _result } + synchronize { (hash[_result.key] ||= []) << _result } end # Retreives all aggregated audits for the specified source. def retrieve(source) synchronize { hash[source] } \ No newline at end of file