J
jc
How can I do the equivalent of the following?
class Foo
class Bar; end
end
Foo::Bar.module # => Foo
class Foo
class Bar; end
end
Foo::Bar.module # => Foo
How can I do the equivalent of the following?
class Foo
class Bar; end
end
Foo::Bar.module # => Foo
What I'm really looking for is a more generic method, something like
Object#parent_namespace:
class A; end
module B
class C
D = A.new
end
end
puts A.parent_namespace => Object
puts B.parent_namespace => Object
puts B::C.parent_namespace => B
puts B::C:.parent_namespace => C
puts B::C:.class.parent_namespace => Object
So that lookups could be easily done:
obj.parent_namespace.const_getname)
obj.parent_namespace.send(name, value)
Is there perhaps a way to do this via the Ruby C API?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.