From: Matthew Kerwin Date: 2012-08-28T13:56:02+09:00 Subject: Re: A Ruby class is never closed On 28 August 2012 14:18, Josh Rendek wrote: > A really simple way to ensure a class doesn't get modified: > > class Foo > def Foo.method_added(name) > raise "This class is closed for modification" > end > end > > class Foo > def testing > end > end > Almost. class Foo def Foo.method_added(name) raise "This class is closed for modification" end end class Foo class << self undef method_added def method_added m end end def testing end end -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd