Create “Exception Filters” in Rails Using Execeptional
Scott Fleckenstein has developed a plugin for Ruby on Rails called Exceptional that 'brings exception handling into the world of Rails filters'. The code speaks for itself on this one:
class SampleController < ApplicationController handles AccessDeniedError, :with => :access_denied, :only => [:supah_sekret_akshun] def supah_sekret_akshun ... raise AccessDeniedError ... end private def access_denied render :text => 'no, u kant' end end
There's a bit more to it than that, so check out the official plugin site for examples and how to download the plugin.
December 3, 2006 at 4:35 am
This sort of reminds me of Lisp's before, after, and around AOP stuff for the CLOS.
I know there were some people yakking about AOP libraries on the Ruby List a long while ago... know of any developments in that area?
December 3, 2006 at 4:41 am
Are you referring to AspectR? Unfortunately that page seems kinda old now, although I'm sure I heard something more recent about it..