1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

autoloading guide: adds nesting rule for Kernel#load [ci skip]

This commit is contained in:
Xavier Noria 2014-12-15 18:22:21 +01:00
parent 9d1a405d4a
commit 84e38bbacc

View file

@ -141,13 +141,16 @@ executed, and popped after it.
* The module object following a `module` keyword gets pushed when its body is * The module object following a `module` keyword gets pushed when its body is
executed, and popped after it. executed, and popped after it.
* When a singleton class is opened with `class << object`, said singleton class * A singleton class opened with `class << object` gets pushed, and popped later.
gets pushed when the body is executed, and popped after it.
* When any of the `*_eval` family of methods is called using a string argument, * When any of the `*_eval` family of methods is called using a string argument,
the singleton class of the receiver is pushed to the nesting of the eval'ed the singleton class of the receiver is pushed to the nesting of the eval'ed
code. code.
* The nesting at the top-level of code interpreted by `Kernel#load` is empty
unless the `load` call receives a true value as second argument, in which case
a newly created anonymous module is pushed by Ruby.
It is interesting to observe that blocks do not modify the stack. In particular It is interesting to observe that blocks do not modify the stack. In particular
the blocks that may be passed to `Class.new` and `Module.new` do not get the the blocks that may be passed to `Class.new` and `Module.new` do not get the
class or module being defined pushed to their nesting. That's one of the class or module being defined pushed to their nesting. That's one of the