Method: Listen::QueueOptimizer#_calculate_add_remove_difference
- Defined in:
- lib/listen/queue_optimizer.rb
#_calculate_add_remove_difference(actions, path, default_if_exists) ⇒ Object (private)
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/listen/queue_optimizer.rb', line 69 def _calculate_add_remove_difference(actions, path, default_if_exists) added = actions.count { |x| x == :added } removed = actions.count { |x| x == :removed } diff = added - removed # TODO: avoid checking if path exists and instead assume the events are # in order (if last is :removed, it doesn't exist, etc.) if config.exist?(path) if diff > 0 :added elsif diff.zero? && added > 0 :modified else default_if_exists end else diff < 0 ? :removed : nil end end |