…or: There is a difference between methodname(args) and self.methodname(args)!
The way how ruby deals with private, protected and public messages was a bit unclear to me. So I decided to dig a bit into it and to find out how it is really working. Finally I have irb installed: so lets go and explore.
Now, what does it mean?
- Public methods can (unsurprisingly) be called from anywhere
- Protected methods on an object can be called from that object and from other objects of the same or an derived class
- Private methods cannot be called via <obj>.<methodname>, not even via self.<methodname>! Consequently they can only be called from the very same object, which for example rules out private attributes.