Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Determining where in the inheritance chain a method is defined (ruby).
def Object.method_defined_where(method)
self.ancestors.detect { |a| a.methods(false).include?(method.to_s) }
#Usage - define in your .irbrc and then:
#=> IO
#Alternatively it has been added to my copy of utility_belt:
#For something more in depth, use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment