Class: JSONSchemer::CachedRefResolver

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

Instance Method Summary collapse

Constructor Details

#initialize(&ref_resolver) ⇒ CachedRefResolver

Returns a new instance of CachedRefResolver.



4
5
6
7
# File 'lib/json_schemer/cached_ref_resolver.rb', line 4

def initialize(&ref_resolver)
  @ref_resolver = ref_resolver
  @cache = {}
end

Instance Method Details

#call(uri) ⇒ Object



9
10
11
12
# File 'lib/json_schemer/cached_ref_resolver.rb', line 9

def call(uri)
  @cache[uri] = @ref_resolver.call(uri) unless @cache.key?(uri)
  @cache[uri]
end