Project

General

Profile

Bug #7844

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

Hello, 

 ~~~ruby 
 

   module P 
   
     def m; puts "P"; super; end 
 
   end 
 
   module Q 
   
     def m; puts "Q"; super; end 
   
     include P 
 
   end 
 
   module R 
   
     def m; puts "R"; super; end 
   
     prepend Q 
 
   end 
 
   module S 
   
     def m; puts "S"; super; end 
   
     include R 
 
   end 
 
   class A 
   
     def m; puts "A"; super; end 
   
     prepend P 
   
     include S 
 
   end 
 
   A.new.m #=> P, R, A, S, Q 
 ~~~ 

 This code has five module dependencies, but only two are satisfied. 

 - `Q` Q includes `P`, P, which is not satisfied: `P#m` P#m precedes `Q#m`. Q#m. 
 - `R` R prepends `Q`, Q, which is not satisfied: `R#m` R#m precedes `Q#m`. Q#m. 
 - `S` S includes `R`, R, which is not satisfied: `R#m` R#m precedes `S#m`. S#m. 
 - `A` A prepends `P`, P, which is satisfied: `P#m` P#m precedes `A#m`. A#m. 
 - `A` A includes `S`, S, which is satisfied: `A#m` A#m precedes `S#m`. S#m. 

 Note that all the dependencies can be satisfied at all: 

 ~~~ruby 
 

   A.new.m #=> Q, P, A, S, R 
 ~~~ 

 --  
 Yusuke Endoh <mame@tsg.ne.jp> 

Back