Gavin Kistner
9/1/2006 6:26:00 PM
Damn, hit send too soon. **continues**
I realize that I can do this by defining a method (as below), but for
some reason that feels bad to me. I'd like to do it with Proc objects,
if possible.
# Works by spamming the method namespace.
class Foo
def self.handle_type( type, &proc )
define_method( "dothing_#{type}", &proc )
end
# ...
def do_thing( type )
send "dothing_#{type}"
end
end