On Dec 20, 2007 6:25 AM, Wes Gamble <weyus / att.net> wrote:
> Chris Cummer wrote:
> > If I understand correctly what you're intending, you can sort'a get
> > around it via the following technique in which the public priv_meth()
> > over-rides the private one. This is not ideal though since it leaves
> > priv_meth() public. Is this what you're thinking?
> >
>
> Not exactly.  I need to modify the body of priv_meth, not expose it
> publicly.

This works for me:

irb(main):013:0> class A
irb(main):014:1> def call_a; a; end
irb(main):015:1> private
irb(main):016:1> def a; "a"; end
irb(main):017:1> end
=> nil
irb(main):019:0> A.new.public_methods.grep(/\Acall_a\Z|\Aa\Z/)
=> ["call_a"]
irb(main):020:0> A.new.call_a
=> "a"
irb(main):021:0> class A
irb(main):022:1> private
irb(main):023:1> def a; "new a"; end
irb(main):024:1> end
=> nil
irb(main):025:0> A.new.public_methods.grep(/\Acall_a\Z|\Aa\Z/)
=> ["call_a"]
irb(main):026:0> A.new.call_a
=> "new a"

So it seems that the private method a can be redefined without making it public.
Hope this helps,

Jesus.