The Ruby Object Model and Metaprogramming

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,444
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Sep 14, 2010

Metaprogramming lets you program more expressively. This makes your code easier to write and easier to maintain and extend. Learn both the hows and whys of metaprogramming Ruby from Dave Thomas, one of the most experienced Ruby programmers in the western world.

Initially, metaprogramming Ruby can seem really difficult. There are all these unfamiliar terms: singletons, self, metaclasses, and so on. And things never seem to work quite right the first time—Hmm... maybe it'll work if I change class_eval to instance_eval...

Well, the good news is that it really isn't that complex. You just have to understand the underlying model, and everything falls into place. Dave Thomas has been digging into that model for the last ten years, and has a fresh (and simple) way of looking at it. Now you'll be able to see why metaprogramming works, and how to do it for yourself.

It doesn't matter if you've been programming Ruby for a month or for five years. We bet that you'll learn plenty new in each of these episodes, as Dave digs into both the how and the why of the Ruby object model and metaprogramming.

Category:

Science & Technology

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (10)

Sign In or Sign Up now to post a comment!
  • @bluefootedpig The example here is kind of silly but this technique is useful for dynamically creating named methods using a "macro" method in the class. Rails does this a lot with things like has_many, scope, etc. So when you call the has_many(:friends) macro in your class, it gives your instance all the *friends related methods automatically.

  • The 'tradition' of wanti is the Ecstatic realization that there is no existence or non existence and that we create the world Make it up ourselves along with our

  • The purpose of wanti is love And healing

    And wisdom

    And to redeem zen buddhism and all that remains unsettled after other spiritual practice

    And to make lycaeum.org

    And to make lycaeum.org A cool place again and the internet a trippy n cool nature affirming place

    have fun and attain the meaning of life

    and to celebrate the Gods (who are one and in all!) in a meaningful Non heirachal nonlinear fractal way... in which beings yourself is what must happen and cant not happen even if yr no one

    YOMO

  • question on the second half. I fail to see the purpose of it. It looks fun and kind of cool, but not practical. The overhead expense of writing those methods out is minimal, and if you need to have so many methods, odds are you should just refactor. So I am having difficult figuring out when this would actually be useful. Otherwises, it just adds another layer of indirection which can confuse new people to the project.

  • On the better form of inheritence... i'm confused. How is that better than in like C# where you just assign the new type? C# has a clone method as well, and it clones values like that as well. So I don't see how it is more true? It would appear from the first half that this does what C# does, only in a more obsure way.

  • Great video. Found this very interesting.

  • @PicklePumpers It's the best explanation of the ruby object model I've ever run into

  • Great job, keep them coming :)

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more