Module: MorseCode::Cacheable
Instance Method Summary collapse
Instance Method Details
#cache ⇒ Object
5 6 7 |
# File 'lib/morse_code/cacheable.rb', line 5 def cache @cache ||= {} end |
#fetch(key) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/morse_code/cacheable.rb', line 9 def fetch(key) return cache[key] if cache[key] value = yield cache[key] = value value end |