-
-
Save heftig/607241 to your computer and use it in GitHub Desktop.
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
# Returns a hash of methods organized by their owner and method type. | |
module Kernel | |
def methods | |
output = {} | |
syms = [:public_methods, :protected_methods, :private_methods] | |
syms.each do |sym| | |
output[sym] = {} | |
send(sym).each do |m| | |
key = self.method(m).owner | |
output[sym][key] ||= [] | |
output[sym][key] << m | |
end | |
end | |
output | |
end | |
end | |
class Module | |
def instance_methods | |
output = {} | |
syms = [:public_instance_methods, :protected_instance_methods, :private_instance_methods] | |
syms.each do |sym| | |
output[sym] = {} | |
send(sym).each do |m| | |
key = self.instance_method(m).owner | |
output[sym][key] ||= [] | |
output[sym][key] << m | |
end | |
end | |
output | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment