From: James Britt Date: 2003-10-16T09:14:10+09:00 Subject: Re: General Ruby Programming questions Eric Hodel wrote: > Simon Kitching (simon@ecnetwork.co.nz) wrote: ... >>Is there any reason why Ruby allows private methods to be invoked like >>this? (rather than provide a tidy alternative for problems like mine). > > > I believe I'm giving a fairly accurate paraphrase of matz when I say > that Ruby doesn't prevent you from writing sloppy code, it just makes it > look ugly enough so that you don't do it. > And if you really want to trap such calls you can override 'send': module SafeSend alias evil_unsafe_send send def send( m, *args ) msg = "No sending of private messages!" raise msg if self.private_methods.include? m.to_s evil_unsafe_send( m, *args ) end end class Foo include SafeSend # ... end