Add if_update option for conditionally updating counter in after_update hook. #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull builds on top of the conditional update functionality. It allows updates to the counter to be made when an update has been made to an embedded/referenced object.
Without this pull, the conditional code is sort of incomplete since you will have to manually increment/decrement the counter when you update the field in the embedded/referenced object that the :if condition depends on.
See the new specs I've added - "should increase counter when old unpublished review is published" and "should decrease counter when old published review is unpublished".