From: dblack@... Date: 2007-07-23T04:29:27+09:00 Subject: Re: How do you "undef_method" for a class method? ---2049402039-2129439823-1185132568=:30757 Content-Type: MULTIPART/MIXED; BOUNDARY="-2049402039-2129439823-1185132568=:30757" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---2049402039-2129439823-1185132568=:30757 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Mon, 23 Jul 2007, Xavier Noria wrote: > El Jul 22, 2007, a las 6:44 PM, Dean Wampler escribi=F3: > >> Module#undef_method and Module#remove_method work fine for instance=20 >> methods, >> but if you specify a class method, your get an error that it doesn't exi= st. >> (I'm using ruby 1.8.6.) > > You need to get into the singleton class: > > (class << Foo; self; end).send(:remove_method, :method) You're doing too much work :-) See Robert D.'s answer: class << Foo remove_method :method end Once you're in the class definition body, you can just go ahead and do things; you don't have to grab the class and address it programmatically unless there's a specific reason. David --=20 * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) ---2049402039-2129439823-1185132568=:30757-- ---2049402039-2129439823-1185132568=:30757--