[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Overriding private methods

snacktime

10/26/2007 4:10:00 PM

So I'm hacking on rails and in activerecord there are two methods that
have public and private versions. I need to override the private
method. How would I go about doing that?

Chris

1 Answer

Evan Moseman

10/26/2007 9:38:00 PM

0


On Oct 26, 2007, at 12:09 PM, snacktime wrote:

> So I'm hacking on rails and in activerecord there are two methods that
> have public and private versions. I need to override the private
> method. How would I go about doing that?
>
> Chris
>

If I understand what you are trying to do, this is typically how I do
that:

class Private
def run_func
you_cant_change_me
end

private
def you_cant_change_me
puts "you can't change me!"
end
end

class Private
private
def you_cant_change_me
puts "you changed me!"
end
end

a = Private.new
a.run_func

--
Evan