On Tue, Mar 13, 2007 at 08:51:02PM +0900, Stefano Crocco wrote: > Alle marted13 marzo 2007, Mark Somerville ha scritto: > > I don't understand why I need > > to wrap the alias_method inside class << self. Can anyone explain it to me? > > alias_method works for instance methods (i.e, a method of instances of class > BigDecimal). You're aliasing a class method (new), that is an instance method > of the class BigDecimal. To do so, you should enter a scope where self is not > the class BigDecimal, but BigDecimal's class. This way, new is seen as an > instance method (i.e. a method of instances of the class of BigDecimal, i.e. > of BigDecimal). This is what you do with the class << self construct. > > I hope this explaination makes sense (if it doesn't, tell me and I'll try to > clarify) Thanks a lot Stefano, that explanation was exactly what I needed. Mark