converted ActiveSupport's magic into explicit Ruby code