From: Bill Kelly Date: 2009-10-29T11:55:59+09:00 Subject: Re: selective module include From: "Michael Guterl" > > You may want to look at Daniel Berger's "use" library. Although I > cannot find it anywhere, he does mention it in ruby-talk:316199 and > includes the source code in the message. > > http://www.nabble.com/Help,-Ruby-1.8.6-p287-broke-my-%22use%22--library-and-I-don%27t-know-why-td19706284.html Thanks! That got me started. I ended up with the following, which seems to behave as I'd hoped. class SpartanObject < BasicObject include ::Kernel keep = BasicObject.public_instance_methods + BasicObject.protected_instance_methods + BasicObject.private_instance_methods + %w( catch class inspect object_id raise throw to_s is_a? kind_of? nil? respond_to? ).map {|m| m.to_sym} (public_instance_methods + protected_instance_methods + private_instance_methods).each {|m| undef_method m unless keep.include? m} end Regards, Bill