Just noticed something interesting (well not that interesting). Ternary operators in Ruby can be re-written using Boolean operators e.g.
method = object.respond_to?(:foo) ? :foo : :bar
would become…
method = object.respond_to?(:foo) && :foo || :bar
Simply replace ?
with &&
and :
with ||
I don’t know if there is any performance gain here, anyone care to investigate?