Skip to content

Add :on option to publish_changes_with #80

@rhnasc

Description

@rhnasc

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions