Videos tagged with Ruby Metaprogramming


Ruby Metaprogramming: Free Episode

Ruby Metaprogramming: Free Episode

Posted in Development

Watch some free extracts from Episodes 2 and 3. (9 mins, QuickTime | Ogg) 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. Th...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming



Ruby Metaprogramming Episode 7: More Hook Methods

Ruby Metaprogramming Episode 7: More Hook Methods

Posted in Development

We’ll pick up where we left off in the last episode by looking at two more Ruby hook methods: included and method_added. But we’ll also take it a step further. We’ll use these hook methods to develop a metaprogramming library that traces the execution of a Ruby program. Along the way we’ll see all the various subtle (and important!) things you need to think about when yo...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming, hook


Ruby Metaprogramming Episode 6: Some Hook Methods

Ruby Metaprogramming Episode 6: Some Hook Methods

Posted in Development

Ruby hook methods are a way for your application to hook itself into the execution of the Ruby interpreter. Using hook methods is crucial for some kinds of metaprogramming, and they can make your code more flexible. In this episode, we’ll see how to use two powerful hook methods: inherited and const_missing. Overriding hook methods to intercept and deal with certain Ruby interpreter event...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming


Ruby Metaprogramming Episode 5: Nine Examples of Metaprogramming

Ruby Metaprogramming Episode 5: Nine Examples of Metaprogramming

Posted in Development

Here’s where all the theory and practice comes together! We’ll take a simple problem and find nine different ways of attacking it using metaprogramming techniques. Adding behavior directly inside the class Using subclassing to add behavior Subclassing with a generator using Class.new Using a ghost class Ghost class with a generator using class_eval Rewrite the method with alias_meth...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming


Ruby Metaprogramming Episode 4: instance_eval and class_eval

Ruby Metaprogramming Episode 4: instance_eval and class_eval

Posted in Development

Two of the workhorse methods of metaprogramming are instance_eval and class_eval. They allow you to execute chunks of code dynamically. Here we’ll see how to use them. How instance_eval and class_eval differ When to use one versus the other Breaking down barriers Creating methods on the fly, but without using closures Defining stuff in classes given a class object Writing DSLs in a block ...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming



Ruby Metaprogramming Episode 3: Dynamic Code

Ruby Metaprogramming Episode 3: Dynamic Code

Posted in Development

Metaprogramming is sometimes defined as “writing code that writes code.” Here we’ll see just how to do that in Ruby. Blocks and the two kinds of block-objects How bindings capture execution context How blocks can act as closures, and why that’s vital to metaprogramming Writing methods that define other methods using nested defs Using define_method Writing your own access...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming


Ruby Metaprogramming Episode 2: Sharing Behavior

Ruby Metaprogramming Episode 2: Sharing Behavior

Posted in Development

One of the primary goals of good design is to put the right behavior in the right place without duplication. We’ll see three ways Ruby excels at this: Using prototype-based programming, where you can create hierarchies of objects with controlled sharing of both state and behavior, and without a class definition in sight. using inheritance (but you can only watch this section after you&rsq...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming


Ruby Metaprogramming Episode 1: Objects and Classes

Ruby Metaprogramming Episode 1: Objects and Classes

Posted in Development

Just what is a Ruby object, and how can Ruby move you away from class-oriented development and back to object-oriented development? Learn about: the internals of objects, how classes really aren’t anything special, what self does, and the two ways it can get changed the method call mantra: “one to the right, then up,” singleton methods and ghost classes, why class methods don&...

Tags: Ruby, Metaprogramming, OOP, The Pragmatic Programmers, Ruby Metaprogramming


Ruby Metaprogramming: Application preview

Ruby Metaprogramming: Application preview

Posted in Development

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 ...

Tags: Ruby, Metaprogramming, The Pragmatic Programmers, Ruby Metaprogramming