31. Meta-programming
...is about programs that write programs
...it’s a superb tool for building frameworks
...it’s the key ingredient for building domain-specific
languages
32. Ruby is a great language for meta-programming because
...is dynamic and reflexive
...open and malleable
...code is data, data is code
...clean unencumbered syntax
...programming event model
33. Rails
...uses the Ruby meta-programming
techniques to accomplish most of its “magic”
...uses meta-programming to bring the language
closer to the problem at hand
...is a domain-specific language for building
web applications
35. All objects are open to modification
You can change a particular instance of a class
Ruby uses a proxy class known as the singleton class
Meta-class: The singleton for Class objects
36. With access to a class object’s meta-class we can
then use Ruby meta-programming techniques to
enhance the class
41. Ruby Meta-programming techniques can be used to
write DSLs that use class methods to enhance
subclasses
Using the meta-class (singleton class) of the subclasses
Rails uses this technique in ActiveRecord
55. There is more to Ruby than Rails!
Building a Framework? Give Ruby a try!
Build the language up towards the problem
Meta-programming is no longer just for the Lisp folks
The future? Powerful Java APIs exposed with Ruby DSLs