From: Caleb Clausen Date: 2006-02-26T15:04:24+09:00 Subject: Re: BlankSlate for lazy.rb (Was: Re: lazy.rb 0.9.5 -- transparent futures!) On 2/25/06, MenTaLguY wrote: > Hmm. Okay, for lazy.rb there are a couple things I would need from > BlankSlate: > > - the ability to "let through" a few additional methods > (just Object#class at the moment, but there may be more later) > > - to be able to hide Object#instance_eval I have a rather mutated version of BlankSlate (as a module) which supports both of these. You can use it something like this: class Foo include BlankSlate hide :instance_eval restore :class end Foo.new.instance_eval{} #=> raises NoMethodError Foo.new.class #=> Foo Is there any chance these features could be included in the gem? I'd love to use it myself, but I need my various changes to it too. Here's the code: module BlankSlate module ClassMethods def restore(*names) names.each{|name| alias_method name, "##{name}"} end def hide(*names) names.each do|name| undef_method name if instance_methods.include?(name.to_s) end end end def BlankSlate.included(othermod) othermod.instance_eval { instance_methods.each { |m| #nothing is thrown away forever, just renamed in a strange way alias_method "##{m}", m #archive m undef_method m unless m =~ /^__/ || m=='instance_eval' } extend BlankSlate::ClassMethods } end end