T
Trans
I'm trying to write a little method called Module#modspace, which will
return the module/class a module/class is defined in. I.e.
Module X
Module Y
Module Z
end
end
end
X::Y::Z.modspace #=> X::Y
So I thought, Module.nesting would help do the trick. But I discovered
the Module.nesting returns the nesting according where it is called in
the code, nothing more. It is like __LINE__ or __FILE__ in this
respect. So it seems to me that it would be more appropriate to define
#nesting in Kernel, not as a class method of Module.
BTW, any help writing Module#modspace appreciated.
T.
return the module/class a module/class is defined in. I.e.
Module X
Module Y
Module Z
end
end
end
X::Y::Z.modspace #=> X::Y
So I thought, Module.nesting would help do the trick. But I discovered
the Module.nesting returns the nesting according where it is called in
the code, nothing more. It is like __LINE__ or __FILE__ in this
respect. So it seems to me that it would be more appropriate to define
#nesting in Kernel, not as a class method of Module.
BTW, any help writing Module#modspace appreciated.
T.