From: "banister (john mair)" Date: 2013-02-15T06:05:26+09:00 Subject: [ruby-core:52266] [ruby-trunk - Bug #7836] Need a way to get Method and UnboundMethod objects to methods overridden by prepended modules Issue #7836 has been updated by banister (john mair). @ marcandre. Another possible approach is to provide `UnboundMethod#super`. We do something similar in our Method wrapper for Pry: https://github.com/pry/pry/blob/master/lib/pry/method.rb#L394-L402 While we're at it, other useful methods for `Method/UnboundMethod` could be private?, public?, aliases, singleton? :) but that could be asking for too much ;) John ---------------------------------------- Bug #7836: Need a way to get Method and UnboundMethod objects to methods overridden by prepended modules https://bugs.ruby-lang.org/issues/7836#change-36297 Author: banister (john mair) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: ruby -v: 2.0.0dev =begin See the following code: module P def hello puts "from P" super end end class A def hello puts 'from A' end prepend P end A.instance_method(:hello).source_location == P.instance_method(:hello).source_location #=> true == Discussion Since (({A.instance_method(:hello)})) effectively returns (({P.instance_method(:hello)})) it is impossible to get an (({UnboundMethod})) object to the original (({A#hello})) method. Tools like ((<[Pry]|URL:http://pryrepl.org>)) need to access (({UnboundMethod})) objects to every active method in the system for debugging purposes. == Possible solution Simply allow (({instance_method()})) to take a second boolean parameter, indicating whether methods injected by prepended modules are to be included, it would default to true: example: A.instance_method(:hello) #=> same as P#hello A.instance_method(:hello, false) #=> return strictly A#hello =end -- http://bugs.ruby-lang.org/