Created
July 24, 2015 11:09
-
-
Save robwilliams/7742746dc5f7e753e8aa to your computer and use it in GitHub Desktop.
Generic broadcast for interactors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module InteractorBroadcast | |
extend ActiveSupport::Concern | |
included do | |
after :broadcast_on_success | |
around :broadcast_on_failure | |
end | |
private | |
def broadcast_on_success | |
broadcast :success, context | |
end | |
def broadcast_on_failure(interactor) | |
interactor.call | |
rescue Interactor::Failure => e | |
broadcast :failure, context | |
raise e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment