What you probably want is this:

class CustomLogger < Logger
  %w(debug info warn error fatal unknown).each do |msg|
    eval("def #{msg}(log_zone, msg)\n super(formatter(log_zone, msg))=20
\n end\n")
  end
end

Juilan.


Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) =20
VIDEO #3 out NOW!
http://sensei.zenunit.com/


On 08/04/2008, at 6:38 AM, I=F1aki Baz Castillo wrote:

> El Lunes, 7 de Abril de 2008, Robert Klemme escribi=F3:
>
>> Can you explain why you need this?  Maybe there is a different
>> solution altogether. This redundancy in method definitions is
>> irritating to me and I suspect there might be a better way to achieve
>> what you really need.
>
> Thanks a lot. Finally it was not so important for me as I thought =20
> initially,
> so I can avoid using it. I asked that for the following reason:
>
> I'm using CusomLogger class that inherits from Logger class. And I =20
> want to
> modify some methods, all exactly the same:
>
> 		def debug(log_zone, msg)  super(formatter(log_zone, =
msg))  end
> 		def info(log_zone, msg)  super(formatter(log_zone, msg)) =
 end
> 		def warn(log_zone, msg)  super(formatter(log_zone, msg)) =
 end
> 		def error(log_zone, msg)  super(formatter(log_zone, =
msg))  end
> 		def fatal(log_zone, msg)  super(formatter(log_zone, =
msg))  end
> 		def unknown(log_zone, msg)  super(formatter(log_zone, =
msg))  end
>
> As you can see, all the methods body is exactly the same. I expected =20=

> there
> could be a cool way to do something as:
>
> 		def debug,info,war,error,fatal,unknown(log_zone, msg)
> 			super(formatter(log_zone, msg))
> 		 end
>
> just it.
>
> Thanks a lot for your help.
>
>
>
>
> --=20
> I=F1aki Baz Castillo
>