Using the (n inherited) method, the receiver / class where it is defined can be achieved by doing:
class A
def foo; end
end
class B < A
end
B.instance_method(:foo).owner
With the help of the (n inherited) constant, there is no analog of the method instance_methodor method, therefore, it is not easy. Is it possible to reach the class where it is defined?
class A
Foo = true
end
class B < A
end
B.some_way_to_extract_the_owner_of_constant(:Foo)
source
share