Project

General

Profile

Actions

Feature #5005

closed

Provide convenient access to original methods

Added by lazaridis.com (Lazaridis Ilias) over 12 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:37917]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0