Created
April 13, 2017 20:01
-
-
Save jeremyf/bb4108e17d8769943afff3cb0d429feb to your computer and use it in GitHub Desktop.
Super method definition
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 hello | |
puts 'hello' | |
end | |
end | |
module B | |
def hello | |
puts 'potato' | |
super | |
end | |
end | |
class C | |
include A | |
include B | |
def hello | |
super | |
puts "something" | |
end | |
end | |
c = C.new | |
c.hello | |
# Find the hello instance method for the C class | |
C.instance_method(:hello).source_location | |
# Find the definition of super for the hello instance method for the C class | |
C.instance_method(:hello).super_method.source_location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment