given:
module A
class B
end
end
b = A::B.new
we want to be able to get the module nesting as an array. This can be done if the class is known in advance. eg:
module A
class B
def get_nesting
Module.nesting # => [A::B, A]
end
end
end
But, how to do it for an arbitrary object, so that we could do something like this:
module Nester
def get_nesting
Module.nesting
end
end
b.get_nesting
If we try the above, we get an empty array.