Create my own dynamic "finder" method?

Hi all

I’m having an authorization method that looks like the following:

def user_requests_authorization_to(right_name)

end

I find it boring to always use

user_requests_authorization_to(‘EDIT’)
user_requests_authorization_to(‘CREATE’)

etc., so I thought I could implement my own dynamic method, like the
dynamic finders! Instead of the calls above I’d like to call

user_requests_authorization_to_edit
user_requests_authorization_to_create

How can I achieve that? :slight_smile: Thanks a lot, Josh

On 23 Nov 2007, at 13:31, Joshua M. wrote:

etc., so I thought I could implement my own dynamic method, like the
dynamic finders! Instead of the calls above I’d like to call

user_requests_authorization_to_edit
user_requests_authorization_to_create

You need to override method_missing, ie

def method_missing(method_id, *arguments)
if method_id looks like user_requests_authorization_to_something
user_requests_authorization_to(something)
else
super
end
end

Fred

Thank you :slight_smile: