Class: JSONSchemer::CachedResolver
- Inherits:
-
Object
- Object
- JSONSchemer::CachedResolver
- Defined in:
- lib/json_schemer/cached_resolver.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(&resolver) ⇒ CachedResolver
constructor
A new instance of CachedResolver.
Constructor Details
#initialize(&resolver) ⇒ CachedResolver
Returns a new instance of CachedResolver.
4 5 6 7 |
# File 'lib/json_schemer/cached_resolver.rb', line 4 def initialize(&resolver) @resolver = resolver @cache = {} end |
Instance Method Details
#call(*args) ⇒ Object
9 10 11 12 |
# File 'lib/json_schemer/cached_resolver.rb', line 9 def call(*args) @cache[args] = @resolver.call(*args) unless @cache.key?(args) @cache[args] end |