Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created April 13, 2017 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/bb4108e17d8769943afff3cb0d429feb to your computer and use it in GitHub Desktop.
Save jeremyf/bb4108e17d8769943afff3cb0d429feb to your computer and use it in GitHub Desktop.
Super method definition
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