Filter customization

It’s more of a Ruby question than Rails specifically, but anyway…

I’m trying to make a generic filter that could be customized with
options (it’s for authorization, but that doesn’t matter).

Currently I see two sensible approaches:

before_filter { |controller| controller.authorize_filter(OPTIONS) }

where authorize_filter is a controller’s method and does the work
depending on options, and:


where create_authorizator returns a Proc object.

I have implemented the second one since, depending on OPTIONS, the
resulting filters may be quite different, so I’m returning different
blocks of code.
The problem is that Proc returned by create_authorizator doesn’t have
access to protected methods of controller (obvious).

The first solution seems less elegant to me, but since it can use
protected methods I’ll have to switch to it.

Do you know of any other/better ways of achieving something similar?

Marcin S.