From: John Higgins Date: 2011-07-12T04:26:58+09:00 Subject: [ruby-core:38007] [Ruby 1.9 - Bug #5015] method_added" is called in addition to "method_undefined Issue #5015 has been updated by John Higgins. Lazaridis Ilias wrote: > John Higgins wrote: > > Lazaridis Ilias wrote: > > > John Higgins wrote: > > > [...] > > > > > > Mr. Higgins, you could write a book in your non-technical tenor about this issue, the fact remains: > > > > > > * callback: added any_method # false callback, "any_method" was *not* added by user > > > > Would you care to, even in passing, explain how I'm incorrect when it comes to the Child class example I gave? > [...] > > No, I can't, because it is irrelevant (and thus I do not invest any energy to analyse). I've provided a use-case. In context of this use-case, the callback "method_added :capitalize" is false, and thus a defect. There's really no need to change context or use-cases: the defect in this use-case remains. Again, what are you basing this on? I asked you what rule/concept states that internal implementations cannot fire callbacks. Why is it an error if the implementation of undef_method adds a method to the class? Where is the definition of undef_method that states anything about its implementation? In fact the docs state only the following "Prevents the current class from responding to calls to the named method." - why exactly is that at odds with a method_added callback being fired during the execution of an undef_method call? Would you only call this a bug in a class with a "direct" definition of a method (i.e. non-inherited method). What about the user that wants to track the addition of the "blocking" method to the subclass if you wanted the method_added subclass suppressed even in a subclass without a direct definition of a method? ---------------------------------------- Bug #5015: method_added" is called in addition to "method_undefined http://redmine.ruby-lang.org/issues/5015 Author: Lazaridis Ilias Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.2 When a method is undefined via "undef_method :any_method", the following methods are called back: * method_added * method_undefined The expected behaviour is that only "method_undefined" is called (similar to "remove_method"). - class String def self.method_added(id) puts "callback: added #{id.id2name}" end def self.method_undefined(id) puts "callback: undefined #{id.id2name}" end def self.method_removed(id) puts "callback: removed #{id.id2name}" end end puts "\nundef method (buildin)" class String undef_method :capitalize end puts "\ndefine method" class String def any_method(*args) nil end end puts "\nundef method" class String undef_method :any_method end puts "\ndefine method" class String def any_method(*args) nil end end puts "\nremove method" class String remove_method :any_method end - OUTPUT: undef method (buildin) callback: added capitalize callback: undefined capitalize define method callback: added any_method undef method callback: added any_method callback: undefined any_method define method callback: added any_method remove method callback: removed any_method -- http://redmine.ruby-lang.org