This is amazing and probably deserves to be its own gem.  (not saying you should do that now)