From: "Mauricio Fernández" Date: 2003-02-04T02:12:00+09:00 Subject: Re: Fun with singletons' singleton classes On Tue, Feb 04, 2003 at 01:05:50AM +0900, ts wrote: > >>>>> "M" == Mauricio =?iso-8859-1?Q?Fern=E1ndez?= writes: > > M> class A > > def self.singleton_method_added id > puts "Adding singleton method #{id} to #{self}" > end > > M> def self.method_added id > M> puts "Adding method #{id} to #{self}" > M> end > How do I do within singleton_method_added to remove a singleton method if it matches some :name? I tried class << self def singleton_method_added i remove_method i if i == :method_added end end and (more sensible) def singleton_method_added i (class << self; self; end).instance_eval <<-EOF remove_method :#{i.to_s} if :#{i.to_s} == :method_added EOF end I want to render impossible to redefine SomeClass.method_added without freezing the singleton of SomeClass. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com The only other people who might benefit from Linux8086 would be owners of PDP/11's and other roomsized computers from the same era. -- Alan Cox