Project

General

Profile

Actions

Feature #1102

closed

Prepend Module

Added by trans (Thomas Sawyer) over 13 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:21822]

Description

=begin
Currently when a module is included into a classes, it is appended to the class hierarchy (ie. the method lookup order). This of course makes sense, but there are times when it would be useful to prepend the module. For example:

class C
def x; "x"; end
end

module M
def x; '[' + super + ']'; end
end

class C
prepend M
end

C.new.x #=> "[x]"

One big advantage of this is being able to override methods in a safer way, rather than using alias or tricks like alias_method_chain.
=end


Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #6452: Allow extend to override class methodsAssignedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF