Skip to content

Instantly share code, notes, and snippets.

@acook
Created February 7, 2012 20:19
Show Gist options
  • Save acook/1761702 to your computer and use it in GitHub Desktop.
Save acook/1761702 to your computer and use it in GitHub Desktop.
Which class is a method defined on?
module Which
def which symbol
klass = self.is_a?(Class) ? self : self.class
reciever = klass.ancestors.select do |dad|
dad.instance_methods.include?(symbol) || dad.methods.include?(symbol)
end.last
end
end
Object.send :extend, Which
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment