Declare Victory with Class Macros
summary
Shows that attr_reader is a class macro and walks through building a reusable cachable macro that uses define_method to create paired methods (all and all_without_cache), uses prepend and super to intercept calls, and calls a cache fetch to prevent extra API traffic. Extracts a library used at Splitwise to enqueue webhook delivery jobs on create, demos caching exchange rates to avoid free-tier limits, and references the memoize gem as a comparison.
AI-written summary · about
chapters (7)
- 0:00Introduction
- 3:16Class macros in Ruby
- 9:03Real-world class macro examples
- 15:23Cacheable class macro
- 27:47Method interceptors and hooks
- 32:07Putting it all together
- 33:13Summary








