Class: Dhall::Resolvers::RamCache
- Inherits:
-
Object
- Object
- Dhall::Resolvers::RamCache
- Defined in:
- lib/dhall/resolve.rb
Instance Method Summary collapse
- #fetch(key, &block) ⇒ Object
-
#initialize ⇒ RamCache
constructor
A new instance of RamCache.
Constructor Details
#initialize ⇒ RamCache
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 |