Skip to content

Instantly share code, notes, and snippets.

@unenemy
Created December 12, 2019 07:59
Show Gist options
  • Save unenemy/7aedcfca563ace13c5455287a72dafbc to your computer and use it in GitHub Desktop.
Save unenemy/7aedcfca563ace13c5455287a72dafbc to your computer and use it in GitHub Desktop.
ruby method lookup
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