I have a need to invoke methods dynamically by name.
Say I have a method like:
person = Person.find(params[:id])
method_to_invoke = ~~ some code to find the method from a string
containing the method name ~~
I do this in Objective C with something like the following:
setWidthHeight = @selector(setWidth:height:);
setWidthHeight = NSSelectorFromString(aBuffer);
Where SEL is a special type representing an Objective C method
signature, and the @selector directive or
NSSelectorFromString(aBuffer) is used to find the method.
I have a feeling that I’m making this more complicated than need be.
Is it possible to do something as simple as: