Module: Pageflow::ControllerDelegation Private
- Included in:
- EntriesController, RevisionsController
- Defined in:
- app/controllers/concerns/pageflow/controller_delegation.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Allow delegating to another Rack app from a controller action.
Instance Method Summary collapse
-
#delegate_to_rack_app!(app) {|result| ... } ⇒ Object
private
Abort currently executed controller action, call passed Rack app and use its response instead.
-
#dispatch ⇒ Object
private
Override ActionController::Metal#dispatch [1] which returns the Rack response triple generated by the controller.
Instance Method Details
#delegate_to_rack_app!(app) {|result| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Abort currently executed controller action, call passed Rack app and use its response instead. A block can be passed to mutate the response.
9 10 11 12 13 14 |
# File 'app/controllers/concerns/pageflow/controller_delegation.rb', line 9 def delegate_to_rack_app!(app) result = app.call(request.env) yield(*result) if block_given? throw(:delegate, result) end |
#dispatch ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override ActionController::Metal#dispatch [1] which returns the Rack response triple generated by the controller. Calling ‘delegate_to_rack_app!` aborts execution of the current controller action and returns the response of the given Rack app instead.
The second argument passed to ‘throw` is becomes the return value of `catch`. If `throw` is not called, `catch` passes the return value of its block.
27 28 29 |
# File 'app/controllers/concerns/pageflow/controller_delegation.rb', line 27 def dispatch(*) catch(:delegate) { super } end |