Does Ruby provide the namespace path, e.g. something like [:A,:B] for class A::B::C?
Is the following possible?
puts A::B::C.new.namespace_path # => [:A,:B], or even 开发者_如何学Python[A,B]
I think maybe #ancestors is what you're looking for.
So A::B::C.ancestors
or you may just want to self.class.to_s.split("::")
精彩评论