Created
July 5, 2012 11:39
-
-
Save ryoqun/3053226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MySubModule | |
end | |
module MyModule | |
include MySubModule | |
end | |
class MyClass | |
include MyModule | |
end | |
class MyBasicClass < BasicObject | |
end | |
p MyModule.ancestors | |
# => [MyModule, MySubModule] | |
# | |
# should fallback to G(object) | |
# first mod(=MyModule) isn't G(class) and G(object) isn't found in the superclass chain. | |
p MyClass.ancestors | |
# => [MyClass, MyModule, MySubModule, Object, Kernel, BasicObject] | |
# | |
# should fallback to G(object) | |
# first mod(=MyClass) is G(class) and G(object) is found in the superclass chain. | |
p MyBasicClass.ancestors | |
# => [MyBasicClass, BasicObject] | |
# | |
# should not fallback to G(object) | |
# first mod(=MyBasicClass) is G(class) and G(object) isn't found in the superclass chain. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment