Guest User

Untitled

a guest
Apr 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. module IncludeMe;end
  2. module BehindTheScenes;end
  3.  
  4. # Include IncludeMe in a module
  5. module One
  6. include IncludeMe
  7. end
  8.  
  9. # Add an ancestor to IncludeMe
  10. module IncludeMe
  11. include BehindTheScenes
  12. end
  13.  
  14. # Include it in another module after adding that ancestor
  15. module Two
  16. include IncludeMe
  17. end
  18.  
  19. # prints [One, IncludeMe]
  20. puts "ancestors after reverse-order includes: #{One.ancestors.inspect}"
  21.  
  22. # prints [Two, IncludeMe, BehindTheScenes]
  23. puts "ancestors after normal includes: #{Two.ancestors.inspect}"
Add Comment
Please, Sign In to add comment