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.



151
152
153
# File 'lib/dhall/resolve.rb', line 151

def initialize
	@cache = {}
end

Instance Method Details

#fetch(key, &block) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/dhall/resolve.rb', line 155

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

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