Close and Go BackBack to Viget

Hackday: Intro to Ruby Meta-Programming

Justin Marney
Justin Marney, Web Developer, December 17, 2009 0

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 find_by_* methods.

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.

Commenting is not available in this weblog entry.

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Recent Comments

Mee too Dan, I’m having a hard time keeping up with new born scripts..

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


How many minutes in an hour?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.