Remove second argument of `Gitlab::Utils::StrongMemoize#strong_memoize_attr`
The following discussion from !103699 (merged) should be addressed:
-
@splattael started a discussion: (+1 comment) Question (non-blocking) While reading the code of
Gitlab::Utils::StrongMemoize
I've stumbled over the second argument.I understand that Ruby does not allow to use
?
or!
as instance variable name (viainstance_variable_get/set
used to cache the value) but I am wondering if users of this API really need to know this. What if we'd, internally, strip or convert disallowed chars?🤔 Or we could even use a Hash to store values allowing arbitrary names as keys?🤔 My question is: Should we remove the need for the second argument and deal with potentially invalid (strip or convert non-alphanum chars) names internally?
🤔 BTW, if we'd remove the second argument inline definitions would be now more accessible:
strong_memoized_attr def enabled? 1 end # or even strong_memoized def enabled? 1 end # if we decide to drop the _attr suffix as asked elsewhere :sweat_smile:
Again - non-blocking and we can easily follow-up on this if we want to.