Skip to content

Instantly share code, notes, and snippets.

@robwilliams
Created July 24, 2015 11:09
Show Gist options
  • Save robwilliams/7742746dc5f7e753e8aa to your computer and use it in GitHub Desktop.
Save robwilliams/7742746dc5f7e753e8aa to your computer and use it in GitHub Desktop.
Generic broadcast for interactors
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