-
Notifications
You must be signed in to change notification settings - Fork 151
Subscribing responders
Kris Leech edited this page Jun 5, 2014
·
1 revision
class MyController < ApplicationController
def create
my_service = MyService.new
my_service.subscribe(CreateResponder.new(self), prefix: 'on')
my_service.run
end
class CreateResponder
def initialize(controller)
@controller = controller
end
def on_success
controller.redirect_to ..
end
def on_failure
controller.render ...
end
private
attr_reader :controller
end
end
Need to ask a question? Please ask on StackOverflow tagging the question with wisper.
Found a bug? Please report it on the Issue tracker.