Class: JSONSchemer::CachedResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/json_schemer/cached_resolver.rb

Direct Known Subclasses

CachedRefResolver

Instance Method Summary collapse

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