harold 
A gem which acts like a bookkeeper for 'who did what' to a certain context and can apply filtering strategies. The context in this gem is invisible but it can be any structure to which changes need to be applied. Currently this gem has two strategies to filter out changes (known as 'operations'):
Harold::Strategies::Cancel
This strategy cancels out :add and :delete operations to the same identifier.
Usage:
operations = [
Harold::Operation.new('1', :add),
Harold::Operation.new('1', :delete),
Harold::Operation.new('2', :add),
]
Harold::Strategies::Cancel.call(operations)
# returns => [#<Harold::Operation:0x0000 @id="2", @type=:add, @payload={}>]
Harold::Strategies::Update
This strategy transforms :add and :delete operations to an :update
statement based on a mutually shared 'scope'.
Usage:
operations = [
Harold::Operation.new('1', :delete, 'scope' => 1),
Harold::Operation.new('2', :add, 'scope' => 1),
Harold::Operation.new('2', :delete, 'scope' => 1),
Harold::Operation.new('3', :add, 'scope' => 1)
]
Harold::Strategies::Update.new('scope').call(operations)
# returns => [#<Harold::Operation:0x0000 @id="3", @type=:update, @payload={'scope' => 1}>]