012 RR Metaprogramming in Ruby

    0
    72
    • What is metaprogramming
    • AST
    • Ripper
    • method_missing
    • send
    • super
    • defined?(super)
    • alias method chain
    • rdoc
    • rspec

    Guidelines

    • Aliasing/Redifining methods (generally wrong)
    • Dynamic Module generation (Generally right)
    • understand Ruby’s method call lookup
    • understand modules (extend and include)
    • Calling super is usually a good idea
    • If you’re going to monkey patch, make sure that the method isn’t already there
    • Make your changes easy to find
    • class_eval def vs define_method
    • Convenience constructors – In a medium sized project, you should not do this more than 3 times.