David A. Black wrote:
> Hi --
> 
> On Mon, 23 Jun 2008, Luca Scaljery wrote:
> 
>>  end
>>        end_time = Time.now.to_f
>>      alias_method method, :"#{method}_with_timing"
>> :dup
>> "refresh"
>> ./t2.rb:31:in `start_trace': uninitialized constant Class::TIMED_METHODS
>> (NameError)
>>  from ./t2.rb:39
>>
>> Any suggestions why I get this error ?
> 
> Here's a boiled-down version:
> 
> irb(main):001:0> class C; X = 1; end
> => 1
> irb(main):002:0> class << C; X; end
> NameError: uninitialized constant Class::X
> 
> The reason is that there's no constant X in the singleton class of C.
> 
> I also suspect that what's above is not actually cut-and-pasted, since
> you don't actually use "TIMED_METHODS" anywhere :-)
> 
> 
> David

TIMED_M is used:

class << Person
  def start_trace
    TIMED_M.each do |method|
      p "x"
      alias_method method, :"#{method}_with_timing"
    end
  end

Here 'method' is aliased using TIMED_M
-- 
Posted via http://www.ruby-forum.com/.