Module: Philiprehberger::Memo::Wrapper
- Defined in:
- lib/philiprehberger/memo/wrapper.rb
Overview
Wraps methods with memoization via define_method
Class Method Summary collapse
-
.apply(klass, method_name, ttl:, max_size:) ⇒ Object
Apply memoization to a method.
Class Method Details
.apply(klass, method_name, ttl:, max_size:) ⇒ Object
Apply memoization to a method
13 14 15 16 17 18 |
# File 'lib/philiprehberger/memo/wrapper.rb', line 13 def self.apply(klass, method_name, ttl:, max_size:) original = klass.instance_method(method_name) opts = { ttl: ttl, max_size: max_size } define_memoized_method(klass, method_name, original, opts) end |