From: Ross Bamford Date: 2005-12-07T02:12:34+09:00 Subject: Re: getting around access control On Tue, 06 Dec 2005 16:47:45 -0000, wrote: > On Wed, 7 Dec 2005, Ross Bamford wrote: > >> irb(main):025:0> class ClzThree >> irb(main):026:1> protected >> irb(main):027:1> def amethod >> irb(main):028:2> "amethod" >> irb(main):029:2> end >> irb(main):030:1> end >> => nil >> >> irb(main):031:0> ClzThree.new.amethod >> NoMethodError: protected method `amethod' called for >> # >> from (irb):31 >> from :0 >> >> irb(main):032:0> class ClzThree >> irb(main):033:1> public :amethod >> irb(main):034:1> end >> => ClzThree >> >> irb(main):037:0> ClzThree.new.amethod >> => "amethod" >> >> ? > > yeah... technically that works. what i'm doing is having handlered > register > with a controller to process requests based on mime_type. the handler > really > needs to be run in the context of the controller to access all the good > stuff > there but which 'good stuff' is not know a priori so i can't really use > this > approach. also, it's probably bad mojo to start making methods public > that > should be private on an object that's directly exposed to the web ;-) > > cheers. > > -a Phew - I was worried I'd missed a huge part of that section for a moment :) I understand that it's probably not the solution you wanted. It quite worries me sometimes that it's doable at all, but then I remember my arguments in the past with Java, about the difference between protecting for robust design and protecting for protection's sake. (Of course this time it's probably a case of the former :) I think it's good that it's your decision with Ruby though...) -- Ross Bamford - rosco@roscopeco.remove.co.uk "\e[1;31mL"