From: "anuraguniyal (anurag uniyal)" Date: 2013-03-15T03:13:18+09:00 Subject: [ruby-core:53420] [ruby-trunk - Bug #8091] Class.new is not called when class is created using class keyword Issue #8091 has been updated by anuraguniyal (anurag uniyal). marcandre (Marc-Andre Lafortune) wrote: > Note that if you need to detect class creation, that can be done using the `inherited` callback. I don't want to detect class creation I wan to overload new, which should be possible, at-least it would be elegant if `class X` and 'Class.new` behave similarly ---------------------------------------- Bug #8091: Class.new is not called when class is created using class keyword https://bugs.ruby-lang.org/issues/8091#change-37608 Author: anuraguniyal (anurag uniyal) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 2.0.0p0 =begin When a class is created using ((|class|)) keyword, Class.new is not called but if class is created using ((|Class.new|)) it is obviously called, there seems to be a dyssymmetry between ((|class X|)) and ((|Class.new|)) e.g. class Class class << self alias new_orig new def new(*args) obj = new_orig *args print "created",obj,"\n" obj end end end class X end It doesn't print anything, but Class.new does =end -- http://bugs.ruby-lang.org/