With a(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 # => A
With a(n inherited) constant, there is no counterpart to instance_method
or method
method, so it is not straightforward. Is it possible to achieve 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) # => A