class Umwelt::History::Aggregate
Public Class Methods
new()
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 7 def initialize @engaged = {} @forgotten = [] end
Public Instance Methods
call(episodes)
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 12 def call(episodes) episodes.each do |episode| index_engaged(episode.engaged) collect_forgotten(episode.forgotten) end verify_consistency @fragments = @engaged.slice(*alive_ids).values end
Private Instance Methods
alive_ids()
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 25 def alive_ids @engaged.keys - @forgotten end
collect_forgotten(ids)
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 37 def collect_forgotten(ids) @forgotten.push(*ids) end
fantom_ids()
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 29 def fantom_ids @forgotten - @engaged.keys end
index_engaged(fragments)
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 41 def index_engaged(fragments) fragments.each do |fragment| @engaged[fragment[:id]] = fragment end end
verify_consistency()
click to toggle source
# File lib/umwelt/history/aggregate.rb, line 33 def verify_consistency fantom_ids.empty? || error!("Aggregate failed: fantom ids: #{fantom_ids}") end