7 comments

[ 0.26 ms ] story [ 44.2 ms ] thread
Opens the article

> The title was bait to get you to open this article. But

Closes the article

Your loss, it's a well written article.
I think a lot of people on hn intuit that Rails isn't actually a jit compiler from their knowledge of what Rails actually is and haven't bothered to open the article or comment here on it either. It's clearly some kind of clickbaity metaphor, but I wouldn't know what, as I didn't click on the article either.
(comment deleted)

    class Order < ActiveRecord::Base
      enum :status, { pending: 0, paid: 1, shipped: 2, refunded: 3 }

      def shippable?
        paid? && !refunded?
      end
    end
Bit off-topic but if `:status` is an enum, then `paid? && !refunded?` is equivalent to `paid?`
It should be yes. Well it's ruby, so you could probably overwrite it with your own `def paid?`, but I suspect the `&& !refunded?` is just cruft.
If you found this interesting, and especially if you write Ruby, I cannot recommend Metaprogramming Ruby highly enough. Fundamentally changed the way I think about programming, and opened my mind to what is possible when one frees themselves from dogmatic, generic best practices. It covers these topics in great detail, and uses examples from ActiveRecord and many other gems' implementations of them.