Brad is asking the important question, but it’s also worth pointing out that variable scoping in Ruby (public, protected, private) is merely a suggestion and not a hard barrier like it is in other languages. There’s also this way of calling a private method: obj.send(:oh_you_think_this_is_private?)
Tim Case —
This was done in a real project I worked by a developer who redefined a private method in ActiveResource. I don’t recommend it. But you will encounter these kind of horrible code you need to deal with during upgrade. If you know how this works, you will be able to cleanup the code.
Comments
Why would I want to redefine a private method?
Brad is asking the important question, but it’s also worth pointing out that variable scoping in Ruby (public, protected, private) is merely a suggestion and not a hard barrier like it is in other languages. There’s also this way of calling a private method: obj.send(:oh_you_think_this_is_private?)
This was done in a real project I worked by a developer who redefined a private method in ActiveResource. I don’t recommend it. But you will encounter these kind of horrible code you need to deal with during upgrade. If you know how this works, you will be able to cleanup the code.
Post a comment