Class: Dhall::Resolvers::RamCache

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/resolve.rb

Instance Method Summary collapse

Constructor Details

#initializeRamCache

Returns a new instance of RamCache.



159
160
161
# File 'lib/dhall/resolve.rb', line 159

def initialize
  @cache = {}
end

Instance Method Details

#fetch(key, &block) ⇒ Object



163
164
165
166
167
168
169
# File 'lib/dhall/resolve.rb', line 163

def fetch(key, &block)
  return @cache[key] if @cache.key?(key)

  Promise.resolve(nil).then(&block).then do |result|
    @cache[key] = result
  end
end