Project

General

Profile

Feature #7836

Updated by nobu (Nobuyoshi Nakada) about 11 years ago

=begin 
 See the following code: 

   

 module P 
     
   def hello 
       
     puts "from P" 
       
     super 
     end 
   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)})) A.instance_method(:hello) effectively returns (({P.instance_method(:hello)})) P.instance_method(:hello) it is impossible to get an (({UnboundMethod})) UnboundMethod object to the original (({A#hello})) A#hello method. 

  

 Tools like ((<[Pry]|URL:http://pryrepl.org>)) [Pry](http://pryrepl.org) need to access (({UnboundMethod})) UnboundMethod objects to every active method in the system for debugging purposes. 

 == Possible solution 
 -------------- 

 Simply allow (({instance_method()})) 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 

Back