Remembering super
Yehuda Katz recently wrote a post about good old super
, probably one of the most underused keywords in Ruby, sadly enough. What can I say, it hit right home. It pretty much nailed what’s wrong with alias_method_chain
, and pretty much put in words how I felt about it too. It helped to explain why I get a weird feeling in my stomach when I see how plugins like authlogic implement some of their functionality. To sum up: it just feels wrong.
The Curious Case Of The Bang Method
One of the cool things about Ruby is the possibility to make your method’s intent more expressive using the question mark or the bang. There’s no need to argue about the use of the question mark method, their intent is to ask something, whether it’s the the status of an object or if the current weather is suitable for getting out your longboard. Their result will usually be true or false, including nil or not nil.
run_later Gets Some Rails 2.3 Middleware Love
Apart from the awesome new features for users of the framework, Rails 2.3 got a lot of love on the inside too. It’s no secret it’s running on Rack now, and that switch made some of the internal code a lot easier on the eyes. They also added a Rails-internal middleware stack, on which some of the framework’s functionality builds already.
XRay Goggles For Your Ruby Processes
The guys over at Pivotal Labs wrote a small piece on a neat tool called XRay. It hooks into your Ruby code to provide Java-like signal handlers which dump the current stack trace into whatever log file seems fit. Using Passenger that’ll be your Apache’s error log file.
Parallelizing Capistrano
On a recent project we ran into a situation where we needed a more advanced way of parallelizing Capistrano tasks than just using the parallel method it already sports. To jog your memory, parallel can run arbitrary shell commands in parallel on different servers. So if you wanted your webserver to already restart the processes while you restart your background processes, you can do it like this: