module MorseCode::Cacheable
Public Instance Methods
cache()
click to toggle source
# File lib/morse_code/cacheable.rb, line 5 def cache @cache ||= {} end
fetch(key) { || ... }
click to toggle source
# File lib/morse_code/cacheable.rb, line 9 def fetch(key) return cache[key] if cache[key] value = yield cache[key] = value value end