Sha256: ca855f4a07af571d9106bb1c1a58ff2f81203a455479fe8c4f52f16de325f287

Contents?: true

Size: 330 Bytes

Versions: 14

Compression:

Stored size: 330 Bytes

Contents

# frozen_string_literal: true
module JSONSchemer
  class CachedResolver
    def initialize(&resolver)
      @resolver = resolver
      @cache = {}
    end

    def call(*args)
      @cache[args] = @resolver.call(*args) unless @cache.key?(args)
      @cache[args]
    end
  end

  class CachedRefResolver < CachedResolver; end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
json_schemer-2.3.0 lib/json_schemer/cached_resolver.rb
json_schemer-2.2.1 lib/json_schemer/cached_resolver.rb
json_schemer-2.2.0 lib/json_schemer/cached_resolver.rb
json_schemer-2.1.1 lib/json_schemer/cached_resolver.rb
json_schemer-2.1.0 lib/json_schemer/cached_resolver.rb
json_schemer-2.0.0 lib/json_schemer/cached_resolver.rb
json_schemer-1.0.3 lib/json_schemer/cached_resolver.rb
json_schemer-1.0.2 lib/json_schemer/cached_resolver.rb
json_schemer-1.0.1 lib/json_schemer/cached_resolver.rb
json_schemer-1.0.0 lib/json_schemer/cached_resolver.rb
json_schemer-0.2.25 lib/json_schemer/cached_resolver.rb
json_schemer-0.2.24 lib/json_schemer/cached_resolver.rb
json_schemer-0.2.23 lib/json_schemer/cached_resolver.rb
json_schemer-0.2.22 lib/json_schemer/cached_resolver.rb