Project

General

Profile

Feature #2065

Updated by nahi (Hiroshi Nakamura) almost 13 years ago

=begin 
  
  I have implemented DSLs that add features to a class/module that should be inherited like methods.    In those cases I end up iterating ancestors to find the first time a feature has been added (the same way I imagine methods are determined). 
 
  The issue is that SomeClass.ancestors regenerates the ancestors array each time it is called.    Therefore this is relatively slow: 
 
    SomeClass.ancestors.each do |ancestor| 
      # ... 
    end 
 
  It would be nice if there were a method that iterates ancestors without generating the ancestors array: 
 
    SomeClass.each_ancestor do |ancestor| 
      # ... 
    end 
 
  This could improve the performance of DSLs that want to support method-like inheritance. 
 
 =end 
 

Back