Hi,

  In mail ""friend" alternative in Ruby?"
    kturing / yahoo.com (kate turing) wrote:

> I have a class "Foo". It has a method "doSecretStuff" that I want to
> be callable from within class "FooManager". But I don't want
> "Foo.doSecretStuff" to be completely public.
> 
> I could compromise and just make "Foo.doSecretStuff" public. But
> surely there's a way. How would the Ruby experts accomplish this?

You can use Object#__send__ to call private methods.

  class Foo
    private
    def doSecretStuff
      puts 'ok'
    end
  end

  #Foo.new.doSecretStuff           # causes error
  Foo.new.__send__ :doSecretStuff   # this is OK

-- Minero Aoki