Very interesting post (From Octobre 23) about object shape in a Rails context.
TL;DR (cf bottom of the article): Define your instance_variable in the constructor if you use memoization to avoid cache miss during ObjectShape inspection
https://railsatscale.com/2023-10-24-memoization-pattern-and-object-shapes/