Skip to content

Instantly share code, notes, and snippets.

@ryoqun
Created July 5, 2012 11:39
Show Gist options
  • Save ryoqun/3053226 to your computer and use it in GitHub Desktop.
Save ryoqun/3053226 to your computer and use it in GitHub Desktop.
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