Project

General

Profile

Feature #12737

Updated by mame (Yusuke Endoh) about 3 years ago

How about to provide Module#defined_refinements, which returns the refinements defined in the receiver as a Hash, as follows: 

 ``` 
 module M 
   refine String do 
     $M_String = self 
   end 

   refine Integer do 
     $M_Integer = self 
   end 
 end 

 p M.defined_refinements Module.defined_refinements #=> {String => $M_String, Integer => $M_Integer} 
 ``` 

 By `Module#defined_refinements`, you can activate refinements globally: 

 ``` 
 for klass, refinement in Module.defined_refinements 
   klass.prepend(refinement) 
 end 
 ``` 

Back