Created
December 12, 2019 07:59
-
-
Save unenemy/7aedcfca563ace13c5455287a72dafbc to your computer and use it in GitHub Desktop.
ruby method lookup
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
class A | |
def action | |
puts 'A' | |
super if defined?(super) | |
end | |
end | |
module B | |
def action | |
puts 'B' | |
super if defined?(super) | |
end | |
end | |
module C | |
def action | |
puts 'C' | |
super if defined?(super) | |
end | |
end | |
module D | |
def action | |
puts 'D' | |
super if defined?(super) | |
end | |
end | |
class E < A | |
include B | |
prepend C | |
def action | |
puts 'E' | |
super if defined?(super) | |
end | |
end | |
object = E.new | |
object.extend(D) | |
object.action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment