Skip to content

Instantly share code, notes, and snippets.

@andrewberls
Created December 23, 2013 00:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewberls/8090332 to your computer and use it in GitHub Desktop.
Save andrewberls/8090332 to your computer and use it in GitHub Desktop.
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