'method_missing' Should be Missing
summary
Claims that method_missing is overused and hides bugs, recommending define_method for roughly 80% of cases; shows a REST-proxy example where regex-based method_missing masks NoMethodError and causes edge cases. Warns that monkey patching (overriding core methods like freeze) breaks upgrades and suggests mixing modules or Ruby 2.0 refinements instead. Demonstrates eval abuses — dynamic constant/variable tricks and even a tested system rm -rf case — and replaces eval with const_get/const_set and instance_variable_get/set for safety.
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:37Who am I
- 2:51Outline
- 3:51Metaprogramming
- 5:30Edge Cases
- 6:36MethodMissing
- 10:29Monkey patching
- 11:30Problems with monkey patching
- 13:18Why monkey patching
- 14:09Evil eval
- 17:20module function
- 18:56class variable
- 20:58eval
- 22:57stay within bounds
- 24:12QA
related talks
42mRuby 2 Methodology
25mIn Defense of Ruby Metaprogramming
18mMetaprogramming: Unraveling the Magic
38mCool, But... Why?
29mBoring Ruby Code
28mDiving into Dynamic: Demystefying Metaprogrammaing with Ruby
29mControl methods like a pro: A guide to Ruby's awesomeness, a.k.a. metaprogramming
33mYour Bright Metaprogramming Future: Mistakes You'll Make (and How to Fix Them)
