RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  

netghost — 37 posts

The Serialization Duck Type
We're going to take a look at common Duck Types in Ruby.

First off, let's take a look at the Serialization Duck Type and see how it provides a simple informal interface for converting objects to and from strings.
Reading Rails - TimeWithZone
Timezones are not fun.

Thankfully, Rails largely deals with them behind the scenes.
Learn how TimeWithZone works, and when you run into that crazy timezone bug, you'll know where to start looking.
Take a look at one of the more popular facets of metaprogramming today, calling and receiving methods using send and method_missing.

We'll wrap it up with a neat example that implements a jQuery like collection in just a few lines of code.
Want to do some more metaprogramming? Heck yes you do!

Come along and learn how to monkey with Ruby's methods. We'll introspect on methods, build a method decorator, and learn a neat syntax trick.

It's going to be great.
Want to learn more about metaprogramming in Ruby?

Of course you do! We're going to look at how to build classes dynamically in Ruby.

Second in a series, perfect for anyone who wants to see some practical metaprogramming in action.
MetaRuby - An Ounce of Meta
Want to do some simple metaprogramming? Have you ever wondered how things like attr_reader work? Unlike languages like Java we can easily define our own language constructs.

Drop by and learn how to write some Ruby that writes Ruby.
Crypto doesn't have to be intimidating.

Dig into Rails's MessageEncryptor and learn how Rails uses it to perform symmetric encryption. You may well be using it already, you might as well find out how it works.
How well do you understand how crypto is implemented in Rails?

The best way to learn is to dig in, so join me as we read MessageVerifier's source. There are a surprising number of interesting topics packed into this tiny class.
Want to learn a little more about how ActiveRecord is implemented? I knew it!

We'll learn how batched queries work by reading the Rails source.
Ack, I know design patterns! This time around instead of reading one specific class, we will be looking at a few real world examples of the Adapter Pattern in Rails.

So, come along and we'll hunt the Rails source for examples of the Adapter pattern.
Are you a curious developer? I sure hope so.

Come along and learn a little more about how Rails' Validation Errors and Validators work as we read the Rails source code.
I've just republished an old series that was languishing on my defunct wordpress blog. If you're curious about how pieces of the ruby standard library work, take a look.

It covers bits and pieces like TSort, Pathname, and Abbrev.
You use them every day, now it's time to learn what's going on under the hood.

Come along and learn how migrations are configured. We'll pick up a few new Ruby idioms, and uncover some functionality in validations you probably haven't seen.
Reading Rails - Concerns
You probably include ActiveSupport's Concerns in your Rails code, but how do they work?

We'll read Rails' Concern Implementation, and learn a bit more about modules, ruby idioms, and more. Come along if you want to understand your libraries.
You probably use ActiveRecord on a daily basis, but how familiar are you with the actual code?

We're taking a look at how Rails tracks applied migrations. While we do so, we'll pick up a few new idioms and learn a thing or two about Ruby.
Reading Rails - Migrations
Come along and read some of the Rails source with me.

We're going to examine one of the most overlooked workhorse of Rails, the Migrator. How does it find migrations? How does it load them? We will also unearth a whole treasure trove of practical (and impractical) Ruby knowledge.
In this installment, we're going to dig into the Rails source and figure out how Rails uses metaprogramming to implement methods like name_changed? for your attributes.

Along the way, we'll pick up some new tricks, and learn a few more esoteric bits of Ruby.
You know how to use ActiveRecord, but do you know how it works?

We're reading the rails source code, to see what we can learn mining it's darker corners.

This time we'll how Rails tracks attribute changes, and unearth some other interesting tidbits along the way.
Ok, so you know how to use Rails.

Come along and we'll read the rails source code, and see what we can learn by mining some of it's darker corners.

First up is rescue_from, how does it register handlers, find them in a crisis, and use them.
Take a look at how to implement Tagging With ActiveRecord 4 and Postgres.

This is a practical look at how you can use ActiveRecord 4's new support for SQL arrays to build tagging into your application.
The Strange Ruby Splat
Is your code too readable? Do your co-workers complain that it always makes sense? The check out ruby's splat operator. Actually it's pretty neat, I cover some useful and some questionable uses for it.
Come take a look at how ruby implements the proxy pattern with Delegator with me in another part of my ongoing series covering the ruby standard library. You'll get to see the canonical use of method_missing, and a neat trick concurrency trick as well.
It's time for another look at ruby's standard library. This time we learn about the uses and implementation of ruby's WeakRef. If you find yourself tracking down memory leaks, this might just be what you're looking for.
Today I have another installment in my series on the ruby standard library. We take a look at how timeout works and what to use it for. If you haven't looked at Timeout's source, you might be surprised at how simple it really is.
I just finished up a fairly large update to Qwandry, a tool for quickly opening libraries, projects, and packages. For all you polyglot programmers you can now easily use Qwandry to launch your ruby libraries and gems, perl, python, and node libraries as well.

Go forth and qw qw
We continue our exploration of ruby's standard library by looking at how Pathname works, and what we can learn from it.
Once again, I walk through an often ignored part of ruby's standard library. This time around, we look at how Abbrev works and what it does.
Here are some handy Hash tricks that take advantage of Hash's initialization block.
We will take a look at ruby's TSort which allows us to untangle dependencies and do some interesting graph processing. Well worth a look if you have never heard of TSort since you already have it installed.
Take a look at ruby's MiniTest::Mock with me. We will see what the mocking library built into ruby 1.9 looks like, and most importantly, how it works.
Come along with me as I take a walk through Shellwords, an interesting part of the standard library that often gets overlooked.
There's been a bit of chatter about ruby's standard library lately, so I thought I might write about some of the more interesting parts. First off, lets have a look at minitest.
Qwandry is a little tool for quickly opening all those gems, files in ruby's standard lib, etc. from the command line. Is ruby's Date.parse doing something weird? `qw date`. You can also tell it about other languages, and package locations if perhaps you want to use it with Node.js and npm or any other file repository. I also wrote up a little bit more about the motivation for Qwandry, if you're interested.
RubyScope, ruby colored binoculars
First release of RubyScope a tool for doing syntactic queries against your ruby code. Find out where variables are being assigned, classes and methods are defined, and more. A TextMate plugin is coming soon.
SexpPath is a library that defines a neat DSL for pattern matching against S-Expressions, for instance the ruby Abstract Syntax Tree. Kind of like XPath or Regular Expressions for your code.
Just thought folks might be interested in OpenGem. It's a little ruby gem plugin that lets you type in: gem open rails and open it up right in your editor. If you're curious about writing a plugin for ruby gems it's probably a decent starting place.
Check out rubydiff , it's a neat tool for doing high-level diffs on ruby code. I have a longer post about it as well with some examples.