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.



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

def initialize
	@cache = {}
end

Instance Method Details

#fetch(key, &block) ⇒ Object



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

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

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