Skip to content

Instantly share code, notes, and snippets.

@wilson
Created November 17, 2009 23:48
Show Gist options
  • Save wilson/237387 to your computer and use it in GitHub Desktop.
Save wilson/237387 to your computer and use it in GitHub Desktop.
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