On Nov 30, 2009, at 5:47 PM, Alexandre Mutel wrote:

> Currently, i'm using something like
>
> class Module
>  def dyn_const_get(sym)
>    list = name.split('::').inject([Object]) {|hierarchy,name|  
> hierarchy
> << hierarchy.last.const_get(name)}
>    result = nil
>    while !list.empty? && result.nil?
>      begin
>        lookup_in = list.pop
>        result = lookup_in.const_get sym
>      rescue
>      end
>    end
>    result
>  end
> end
>
> And performing : A::C.dyn_const_get(:B) returns
> A::B
>
> But that's a very bad option in terms of performance... I'm  
> wondering if
> there are any other options?
> -- 
> Posted via http://www.ruby-forum.com/.
>


Would your DSL rather do something with const_missing instead of  
method_missing? (see Module#const_missing) I suppose that you could  
set A::C::B = A::B

-Rob


Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com