How can I get an instance method in a variable? For example:
class Foo
def bar
puts "bar"
end
end
I want to be able to manipulate the “bar” instance method (for example, to pass it around). How can I do it?
I know that I can get the class constant with
foo_class = Kernel.const_get("Foo")
Is there anything similar I can do to get Foo#bar?
It seems you need an UnboundMethod: