From: Robert Klemme Date: 2008-04-08T17:03:13+09:00 Subject: Re: Is possible to define various methods at same time? 2008/4/8, Robert Klemme : > 2008/4/7, Iñaki Baz Castillo : > > > El Lunes, 7 de Abril de 2008, Robert Klemme escribió: > > > > > > > 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 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 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 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. > > > I agree to Gennady: delegation might be a better choice over inheritance here. PS: I would guess that the original Logger class provides some means to control formatting, for example a pluggable formatter. Why can't you use that? Kind regards robert -- use.inject do |as, often| as.you_can - without end