I'm trying to dynamically call instance methods. I found send, call, eval to do that. There are examples of dynamically calling class methods, but I haven't figured out how to make it work for instance methods.
e.g.
module MyModule
def Foo
puts "hello"
end
end
the instance method names can be listed by:
MyModule.instance_methods
#=> [:Foo]
But I can't figure out how to call the method:
MyModule.send("Foo")
#=> NoMethodError: undefined method `Foo' for MyModule:Module
MyModule.method("Foo").call
#=> NameError: undefined method `Foo' for class `Module'
eval 'MyModule.Foo'
#=> NoMethodError: undefined method `Foo' for MyModule:Module
How can I call the instance methods, like Foo, by the method name?
eval 'MyModule.Foo'is the same asMyModule.Foo.