Exploring ActionController::Responder
Anything that responds to call, accepting three arguments, can be a responder. The three arguments given to call are the current controller, the resource (or a nested resource or an array of resources), and a hash of options. All the options given to respond_with are forwarded to the responder as the third argument.
ActionController::Responder implements the call method in a single line of code, as we can see in the Rails source code:
rails/actionpack/lib/action_controller/metal/responder.rb | |
| def self.call(*args) |
| new(*args).respond |
| end |
The call method forwards these three arguments to the ActionController::Responder initialization and then calls respond:
rails/actionpack/lib/action_controller/metal/responder.rb ... |
Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.