I have to dynamically call a list of methods on an object obj. I am trying to instantiate a method object and then call it.
method_name (a string) is a name of a method which can be called on object obj.
meth=obj.method(method_name) #method_name is a string
meth.call = mod
I am getting the following error:
undefined method `call=' for # (NoMethodError)
I am using Sequel ORM and have to save model associations dynamically. If I directly call method_name (when method_name is not a string) the following is working
obj.method_name = mod #working
However, when method_name is a string, the following is giving a syntax error:
obj.send(method_name) = mod #not working
syntax error, unexpected '=', expecting keyword_end
So I am not able to call the methods from their name in string form using any of the above ways.