Created
December 23, 2013 00:53
-
-
Save andrewberls/8090332 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 A | |
def do_something | |
puts 'A->do_something' | |
super | |
end | |
end | |
module B | |
def do_something | |
puts 'B->do_something' | |
super | |
end | |
end | |
module C | |
def do_something | |
puts 'C->do_something' | |
super | |
end | |
end | |
class Parent | |
def do_something | |
puts 'Parent->do_something' | |
end | |
end | |
class Child < Parent | |
include A | |
include B | |
include C | |
end | |
p Child.ancestors | |
# => [Child, C, B, A, Parent, Object, Kernel, BasicObject] | |
Child.new.do_something | |
# Output => | |
# | |
# C->do_something | |
# B->do_something | |
# A->do_something | |
# Parent->do_something |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment