Would constantize do the trick? I've used it to turn strings into class names. For example:

constantize("Animal").find_by_name("monkey")

There is a whole pile of inflectors:

http://railsmanual.org/module/Inflector/1.1.2

Good luck,

Nathan

Patrick Crowley wrote:
I'm working on a plugin that will include allow users to selectively apply a method to :before_save (or other ActiveRecord callbacks, if specified).

    before_save :some_action

This works, but I'd like to allow plugin users to choose their own callback. Of course, I can do a big fat case statement, but is there a way to use a string to set the method name?

    {callback_string.convert_to_method} :some_action

Any ideas?

-- Patrick




_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby



--
Nathan Colgate Clark
Web Designer and Architect
Brand New Box
(619) 322-9459
www.brandnewbox.com

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to