Take
class A; def foo; end; end
class B < A; end
b = B.new # => #<B:0x0000000243b8c0>
m = b.method :foo # => #<Method: B(A)#foo>
m.owner # => A
m.receiver # => #<B:0x0000000243b8c0>
m.receiver.class # => B
mm = m.unbind # => #<UnboundMethod: B(A)#foo>
How can I get B from mm short of parsing the result of mm.to_s?
I spent some time looking at proc.c and I don’t think it is possible.
Bgets stored inrclassand as far as I can tell it is not accessible anywhere. You can see how it is used here, although I don’t think that helps either.May I ask why do you need to do that? Maybe there is another way to solve the general problem 🙂