Class: Statsig::Memo
- Inherits:
-
Object
- Object
- Statsig::Memo
- Defined in:
- lib/memo.rb
Class Method Summary collapse
- .for(hash, method, key, disable_evaluation_memoization: false) ⇒ Object
- .for_global(method, key) ⇒ Object
Class Method Details
.for(hash, method, key, disable_evaluation_memoization: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/memo.rb', line 6 def self.for(hash, method, key, disable_evaluation_memoization: false) if disable_evaluation_memoization return yield end if key != nil method_hash = hash[method] unless method_hash method_hash = hash[method] = {} end return method_hash[key] if method_hash.key?(key) end method_hash[key] = yield end |
.for_global(method, key) ⇒ Object
23 24 25 26 27 |
# File 'lib/memo.rb', line 23 def self.for_global(method, key) return self.for(@global_memo, method, key) do yield end end |