Overriding private methods

S

snacktime

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
 
E

Evan Moseman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top