From: nobu@... Date: 2014-05-30T07:43:04+00:00 Subject: [ruby-core:62856] [ruby-trunk - Feature #7836] Need a way to get Method and UnboundMethod objects to methods overridden by prepended modules Issue #7836 has been updated by Nobuyoshi Nakada. Description updated Can't you achieve this by `Method#super_method`? ---------------------------------------- Feature #7836: Need a way to get Method and UnboundMethod objects to methods overridden by prepended modules https://bugs.ruby-lang.org/issues/7836#change-46975 * Author: john mair * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto * Category: core * Target version: current: 2.2.0 ---------------------------------------- See the following code: ~~~ruby 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](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: ~~~ruby A.instance_method(:hello) #=> same as P#hello A.instance_method(:hello, false) #=> return strictly A#hello ~~~ ---Files-------------------------------- 0001-proc.c-include-prepended-method-flag.patch (3.17 KB) -- https://bugs.ruby-lang.org/