From: "Mauricio Fernández" Date: 2003-02-04T06:22:44+09:00 Subject: Re: no override On Tue, Feb 04, 2003 at 12:26:37AM +0900, Mauricio Fern�ndez wrote: > It turns out it is quite easy to break as it stands: > > class D < A > class << self > def method_added id > end > end > def a; puts "I won!"; end > end > > D.new.a # ==> "I won!" > > So here's the fix: > > module NoOverloading > def inherited << sub .... > self.freeze > end > end > > A.freeze > NoOverloading.freeze > > this makes absolutely impossible to redefine #a, AFAIK. However, it also > means that you can no longer create class methods. For the record, there's a second way to break it: using alias_method or alias. You can even remove alias_method from Module, but alias is a keyword so there's no way to get rid of that. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com C:\> WIN Bad command or filename C:\> LOSE Loading Microsoft Windows ...