O'Reilly logo

Rails Crash Course by Anthony Lewis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Advanced Ruby

You learned the fundamentals of Ruby back in Chapter 1. This chapter covers some of the language’s advanced features, including modules, the Ruby object model, introspection, and a bit of metaprogramming.

Modules are used frequently in Rails applications to group similar functionality and share behavior between classes. The Ruby object model determines how methods are found and called in a hierarchy of inherited classes and shared code from modules. Introspection supports polymorphism by allowing you to look inside a class to see which methods it understands. Metaprogramming lets your classes respond to methods that don’t exist by defining methods at runtime.

Open a terminal window and launch IRB to get started. Several ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required