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.
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 |