When creating Rails controllers, I often dislike the use of filters such as #before_filter
due to the fact that they can
get a bit unweildy. I'd much rather be able to look at the definition of an action's method and see right in the first few
lines if there are is anything that might run which would cause the action to behave differently.
The nice thing about before-filters, of course, is that you can cancel the running of the action method form within the filter, which is handy for redirects or changing what is rendered in cases such as failed authorization, etc. If you use inline methods to, say, check authorization, and that method does a render or a redirect, you need some way to ensure that the remainder of the action does not execute, so that you avoid both performing unauthorized actions and getting a double-render error from Rails.
What follows is a way to do that by using an application-wide around-filter and using Ruby's throw/catch mechanism to pop back up the stack.