bernsteinbear.com · 12d · discuss
Originally published on Rails At Scale. The title was bait to get you to open this article. But fear not! We will be generating code at run-time today. (See the PR for a sneak peek.) Sam popped into the JIT channel asking how we might optimize Rails enums in Roundhouse, motivated by the following code snippet: class Order < ActiveRecord::Base enum :status, { pending: 0, paid: 1, shipped: 2, refunded: 3 } def shippable? paid? && !refunded? end end In particular, there is a lot of dynamic behavior going on with the code generated by Rails enum and Sam wanted...