Tag Archives: idioms

RSpec is for the literate

A couple years ago I wrote a library called AlterEgo. It’s an implementation of the State Pattern for Ruby. I consider the library to be retired at this point—other libraries, such as State Machine and ActiveModel, have since incorporated all … Continue reading

Posted in Rants | Tagged , , , , , , | 22 Comments

Array-ifying Values

I can’t remember if I’ve written about this before. On the assumption that I haven’t, I’ll forge ahead. As I’ve mentioned in the past I hate null checks. They clutter up code and add nothing meaningful to the code’s narrative. … Continue reading

Posted in Uncategorized | Tagged , , , , | 6 Comments

Writing Self-Confident Code

A common idiom in ruby is to call a method only if its receiver is not nil: thing.foo if thing or: thing && thing.foo Various libraries exist for making this a little more convenient. You can use andand, or if … Continue reading

Posted in Uncategorized | Tagged , , , , , | 17 Comments