Ruby's Object Model was influenced by Smalltalk. The Smalltalk object model follows a set of simple rules that are uniformly applied. The rules are:
Everything is an object.
Every object is an instance of a class.
Every class has a superclass.
Everything happens by sending messages.
Method look-up follows the inheritance chain.
Ruby Object Model
In Ruby, Rule 1 is not applicable. We have seen that everything is not an object. We can say:
- Everything in the inheritance hierarchy is an Object.
- Receiver and Sender in a message sending interaction are objects.
- Every class is an object. In other words, every class is an instance of a Ruby built-in class called Class.
We have already discussed the Rule 3 and 4 in the previous section. In this section, you will learn about Rule 2 and 5.