seniorRuby

Explain Ruby's Object Model, detailing how classes, modules, and singleton classes interact.

Updated May 17, 2026

Short answer

Every object has a class, and every class is an instance of the Class class. Method lookup always moves into the object's hidden singleton class first, then up through its explicit ancestor module/class chain.

Deep explanation

In Ruby, all classes are objects themselves, instances of the class named Class. When a method is called on an object, Ruby does not look directly in the class configuration. Instead, it inspects the object's secret, anonymous metaclass (also known as the singleton class or eigenclass). If the method is not found there, it climbs up the instance's class definition, then moves sequentially through included/prepended modules, and up into parent superclasses, finally hitting Object, Kernel, and BasicObject.…

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Ruby interview questions

View all →