Created
October 2, 2010 03:16
-
-
Save shadoi/607234 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_by_owner | |
output = {} | |
output[:private_methods] = {} | |
output[:instance_methods] = {} | |
output[:protected_methods] = {} | |
self.private_methods.each do |m| | |
key = self.method(m.to_sym).owner.to_s | |
output[:private_methods][key] ||= [] | |
output[:private_methods][key] << m.to_sym | |
end | |
self.instance_methods.each do |m| | |
key = self.instance_method(m.to_sym).owner.to_s | |
output[:instance_methods][key] ||= [] | |
output[:instance_methods][key] << m.to_sym | |
end | |
self.protected_methods.each do |m| | |
key = self.method(m.to_sym).owner.to_s | |
output[:protected_methods][key] ||=[] | |
output[:protected_methods][key] << m.to_sym | |
end | |
return output | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment