rails/rails — Issue #5216: Accessing Parent Module (ruby issue)
Author: homakov
Created: 2012-02-29 08:06:29+00:00
State: open

Hey, I have noticed that ruby didn't get 'parent' method to get parent module. It is really disappointing.
e.g.
```
module A
class B
end

class C
end
end
```
Is there any way to get A being inside A::B?

I have developed method
```
def Object.sibling_const(const)
(@parent_module ||= begin
self.to_s.split('::').tap{|m| m.pop}.inject(Object){|m,v| m.const_get(v) }
end
).const_get(const)
end
```
Do you mind having something similar in ActiveSupport? Because it seems really missing part of ruby class ideology. Need your advice regards this issue, thank you