Thanks, D Y.
Dmitry Shvetsov
1

I would combine what you did and pass the variables with “locals” but still memoize with an instance variable so it’s only looked up once. Just curious, what is your aversion to instance variables?

I value code that’s easier to understand so that’s why instance variables are ok to me in this case. Also, to rephrase my comment about “customer_special_offer_code” - as you said it “acts as a filter and at the same time as a source of indirect”. It’s two different unrelated responsibilities. I think that’s why I dislike it so much.

You also mention before filters being the wrong solution because it makes you “look for more than one place to understand what’s going on” but that’s exactly what “customer_special_offer_code” is doing too :)

But again, it’s an interesting approach I’ve never thought about so appreciate learning about it.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.