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.
@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.
werdnativ 6 days ago
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
rainbowaon 2 months ago
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
rainbowaon 2 months ago
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.
bluefootedpig 4 months ago
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.
bluefootedpig 4 months ago
Great video. Found this very interesting.
mangoswiss 10 months ago
@PicklePumpers It's the best explanation of the ruby object model I've ever run into
LucaPette 1 year ago
Great job, keep them coming :)
bobij0 1 year ago