Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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}"
Add Comment
Please, Sign In to add comment