Created
November 17, 2009 23:48
-
-
Save wilson/237387 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 IncludeMe;end | |
module BehindTheScenes;end | |
# Include IncludeMe in a module | |
module One | |
include IncludeMe | |
end | |
# Add an ancestor to IncludeMe | |
module IncludeMe | |
include BehindTheScenes | |
end | |
# Include it in another module after adding that ancestor | |
module Two | |
include IncludeMe | |
end | |
# prints [One, IncludeMe] | |
puts "ancestors after reverse-order includes: #{One.ancestors.inspect}" | |
# prints [Two, IncludeMe, BehindTheScenes] | |
puts "ancestors after normal includes: #{Two.ancestors.inspect}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment