This gem currently provides the publish_changes_with method, which can be used, for a given ActiveRecord model, to trigger a pub_sub event on an after_commit hook.
The after_commit will be fired whenever an action has been performed on a record, whether it was a touch, update, create or even a destroy action.
However, it's not uncommon to find use cases where we want to send a message only if the action performed was a deletion, or on on any action except deletion. As this method makes no distinction on what actions were made, the developer has to write their own callbacks rather than using this API.
This issue suggests an on option, to be included to the method in question.
Its parameter can be one of those symbols [or array of symbols containing one or more of them]: :create, :update, :save, :destroy, :touch.
Usage:
publish_changes_with :destroy_resource, on: :destroy
publish_changes_with :update_resource, on: [:save, :touch]
This gem currently provides the
publish_changes_withmethod, which can be used, for a given ActiveRecord model, to trigger a pub_sub event on anafter_commithook.The after_commit will be fired whenever an action has been performed on a record, whether it was a touch, update, create or even a destroy action.
However, it's not uncommon to find use cases where we want to send a message only if the action performed was a deletion, or on on any action except deletion. As this method makes no distinction on what actions were made, the developer has to write their own callbacks rather than using this API.
This issue suggests an
onoption, to be included to the method in question.Its parameter can be one of those symbols [or array of symbols containing one or more of them]:
:create,:update,:save,:destroy,:touch.Usage: