From: Xavier Noria Date: 2008-09-07T00:37:41+09:00 Subject: Re: is it possible to turn a private method into a public one? On Fri, Sep 5, 2008 at 11:06 PM, Lex Williams wrote: > could a private/protected method be turned into a public one ? Sure. On the one hand you can circumvect access control with Object#send: object.send(:method_name_even_if_private, ...) And yes, you indeed can change the visibility: class C private def foo puts "it works" end end c = C.new begin c.foo rescue puts $! C.send(:public, :foo) c.foo end # => # private method `foo' called for # # it works That public is similar to the private call in C, only done out of the class and via #send because it is private. It is interesting to note that we've been able to call the method on an object that was created when #foo was private, as the raised exception proves. That's because method calls are resolved on a per call basis due to the dynamic nature of Ruby.