From: ara.t.howard@... Date: 2005-12-06T16:33:10+09:00 Subject: Re: getting around access control On Tue, 6 Dec 2005, Joel VanderWerf wrote: > These are probably not helpful: > > irb(main):012:0> c.instance_eval{ p send(:meth) } > 42 > => nil > irb(main):013:0> c.instance_eval " p meth " > 42 > => nil > > The strange thing is that s/protected/private/ avoids the error: > > irb(main):014:0> class C > irb(main):015:1> private > irb(main):016:1> def m2; 43; end > irb(main):017:1> end > => nil > irb(main):018:0> c.instance_eval{ p m2 } > 43 > > (ruby-1.8.2, anyway) > > The original error (in the protected case) seem uncalled for.... yeah - it's quite strange. unfortunately the 'send' approach won't work because the actual usage is something like class Controller def method handler = Handler::new self handler.encode '42' end end class Handler def initialize controller @controller = controller end def encode msg @controller.instance_eval do # # many things which need to be insider the controller # end end end that 'private' methods __are__ allowed is really strange indeed. regards. -a -- =============================================================================== | ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================