Issue #5005 has been updated by Lazaridis Ilias.


=begin

I've notice a related issue, #3688, which suggests the introduction of "redef". This, in combination of "original", would be an extension more native to the language - avoiding this way to (ab)use the general construct "super(class-method)", which has a very specific meaning in standard OO.

"redef" would allow to keep track of the redefined method.

Another way would be, that the usual "def" detects that a redefinition happens, thus is keeps automatically a copy of the original method, which "original" accesses then.

This way, "original" would take care about multiple redefinitions, calling always the right one, without any effort for the user.

=end

----------------------------------------
Feature #5005: Provide convenient access to original methods
http://redmine.ruby-lang.org/issues/5005

Author: Lazaridis Ilias
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0


The languag allows a class to be "reopened", thus it's behaviour can be redefined:

class String
  def any_method
    #custom code
  end
end

the original method can be called, using this construct:

class String
  alias_method :original_any_method, :any_method
  def any_method(*args)
    #custom code
    original_any_method(*args)
    #custom code
  end
end

In order to make this more convenient, the following construct could be provided:

class String
  def any_method(*args)
    #custom code
    original # call the original String#any_method, passing *args (similar to "super")
    #custom code
  end
end

 "original" would behave similar to "super"

The term "original" can be replaced by any term which describes this concept better.






-- 
http://redmine.ruby-lang.org