Module 24 Β· The Ruby Object Model β Lesson 4 of 6 Β· ~11 min
The Method Lookup Path
When you send a message, where does Ruby look?
This is the object-model question. When you call booking.confirmed?, Ruby walks a strict, ordered list of places looking for a confirmed? method, and runs the first one it finds. That list is the ancestor chain, and you can print it: Booking.ancestors. Every mixin, every superclass, method_missing, and Rails' entire feature set is just careful arrangement of this chain.
In an interview, say: "Method lookup walks the ancestors: singleton class, then the class, then modules it prepends/includes (last included wins, searched bottom-up), then the superclass and its modules, up to
BasicObject. The first match runs.supercontinues the walk from where the current method was found."