If you want to avoid metaprogramming then I recommend setting up a snippet in your editor that expands to a memoized method. For example, when I type memo<TAB> (I use UltiSnips) then the following appears:
def name
@name ||= value
end
UltiSnips keeps name in sync both in the method name and attribute name. Pressing <TAB> one more time takes me to value. You can of course do the same for the more bullet-proof approach described in the article.
If you want to avoid metaprogramming then I recommend setting up a snippet in your editor that expands to a memoized method. For example, when I type
memo<TAB>(I use UltiSnips) then the following appears:UltiSnips keeps
namein sync both in the method name and attribute name. Pressing<TAB>one more time takes me tovalue. You can of course do the same for the more bullet-proof approach described in the article.That’s a good point. I do use RubyMine live templates, and there’s a way to do something like that in most editors.