Skip to content

Instantly share code, notes, and snippets.

@jcoglan
Created August 24, 2008 18:15
Show Gist options
  • Save jcoglan/6999 to your computer and use it in GitHub Desktop.
Save jcoglan/6999 to your computer and use it in GitHub Desktop.
class Module
method = instance_method(:instance_methods)
define_method :instance_methods do |condition = true|
return method.bind(self).call(condition) unless Module === condition
anc = ancestors
index = anc.index(condition) || -1
anc[0..index].inject([]) { |methods, ancestor|
methods.concat(ancestor.instance_methods(false))
}.uniq
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment