Skip to content

Instantly share code, notes, and snippets.

@whatupdave
Created August 5, 2010 07:13
Show Gist options
  • Save whatupdave/509380 to your computer and use it in GitHub Desktop.
Save whatupdave/509380 to your computer and use it in GitHub Desktop.
class Object
def self.instance_methods_by_module
class_methods = []
self.ancestors.reverse.each do |a|
new_methods = a.instance_methods.sort
class_methods.each do |cm|
new_methods = new_methods - cm[1]
end
class_methods << [ a.name, new_methods ]
end
class_methods.reject {|cm| cm[0] == Kernel.name || cm[0] == Object.name }.reverse
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment