class OjSerializers::Memo

Internal: Provides a simple API on top of Hash for memoization purposes.

Public Class Methods

new() click to toggle source
# File lib/oj_serializers/memo.rb, line 5
def initialize
  @cache = {}
end

Public Instance Methods

clear() click to toggle source
# File lib/oj_serializers/memo.rb, line 9
def clear
  @cache.clear
end
fetch(key) { || ... } click to toggle source
# File lib/oj_serializers/memo.rb, line 13
def fetch(key)
  @cache.fetch(key) { @cache[key] = yield }
end