Module.nesting strangeness

A

Alexandre Mutel

Hi,
i'm encountering a weird behavior of the Module.nesting methodd. Here is
my testcase from the irb:

____________________________

class A
class B
def test()
puts "Module.nesting : " + Module.nesting * ","
end
end
end
=> nil

b = A::B.new
=> #<A::B:0x24102d8>

b.test
Module.nesting : A::B,A
=> nil

b.instance_eval { puts "Module.nesting : " + Module.nesting * "," }
Module.nesting :
=> nil
____________________________

The documentation says : "Returns the list of Modules nested at the
point of call. ". But how Module.nesting in test() method knows that it
was declared inside the class A/classB and not outside?
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top