Stupid Ruby tricks

Over at work, I’m rapidly getting up to speed on Ruby and Rails. It’s fun and a little wacky (and, not to mention, very fast-paced for us right now). This snipped cracked me up when I saw Jared use it while debugging.

class Object
  def wtf!
    raise (self.respond_to?(:pretty_inspect) ? self.pretty_inspect : self.inspect)
  end
end

Totally unnecessary, but man is it fun to type request.wtf! when doing initial debugging on a controller.

Tags: ,

Thursday, January 20th, 2011 Geekdom
 

Twitter Feed

Archives