Get the latest tech news
Metaprogramming in Ruby: It's All About the Self (2009)
After writing my last post on Rails plugin idioms, I realized that Ruby metaprogramming, at its core, is actually quite simple. It comes down to the fact that all Ruby code is executed code--there is no separate compile or runtime phase. In Ruby, every line of code is executed against
After writing my last post on Rails plugin idioms, I realized that Ruby metaprogramming, at its core, is actually quite simple. In some of these cases, the multiple ways to achieve the same thing arise naturally out of Ruby's semantics. UPDATE: Thank you to Yugui of the Ruby core team for correcting the original post, which ignored the fact that self is broken into two in the case of instance_eval.
Or read this on Hacker News