Noting highlights from the book Metaprogramming Ruby (2nd Edition).

Chapter 1: The M Word

  • Language constructs - variables, classes, methods
  • Runtime for Ruby is quite different from compiled languages like C++ in that during runtime, many language constructs are still available for introspection
# passing false below only returns instance methods defined by
# ourselves, skipping inherited instance methods

my_object.class.instance_methods(false)

# can peek at an object's instance variables

my_object.instance_variables
  • The M word Metaprogramming is writing code that manipulates language constructs at runtime.