Ruby method memoization