Hackday: Intro to Ruby Meta-Programming
This past Saturday we hosted the third Hackday at Viget Labs (photos). For this round we decided to tackle meta-programming, one of the more mystical features of Ruby. We found, through several conversations at Hacknight, that people were getting the hang of Ruby through their work with Rails, but weren't clear on how things like the
find_by_* methods were implemented. Unlike the previous Hackdays we took a more structured presentation approach, but that didn't reduce the usual amount of collaboration and discussion that makes Hackday unique. We even had a brave audience member do some live meta-programming!
The morning was divided up into two topics: The Ruby Object Model and Meta-Programming in Ruby. I covered the first section in an effort to lay down some foundational knowledge regarding Ruby's internals. Matt did a great job building on top of that material and was able to show some real world examples of meta-programming. He had an audience member come up and live code a pure Ruby implementation of attr_accessor and followed that up with a break down of how Rails uses meta-programming to dynamically build
Thanks to everyone who was able to make it to the event! If you weren't able to make it, or want to go over the topics we covered, we've put up our notes and code examples on GitHub. Feel free to email me or Matt with any follow up questions. We hope to see you all at the next HackNight.