Sha256: c3a0785c39065a300953c0b8b43387328aa7d4d37cc5e53aec2251a3659b107b
Contents?: true
Size: 888 Bytes
Versions: 4
Compression:
Stored size: 888 Bytes
Contents
# frozen_string_literal: true require "concurrent" module Panko # Serialer Descriptor Cache class Cache def initialize @_cache = Concurrent::Map.new end def fetch(serializer_const, options) serializer_key = build_key(serializer_const, options[:only], options[:except]) serializer = @_cache.compute_if_absent(serializer_key) { SerializationDescriptorBuilder.build(serializer_const, only: options.fetch(:only, []), except: options.fetch(:except, []) ) } serializer end private # # Create key based on what we define unique serializer # def build_key(serializer_const, only, except) [serializer_const, only, except].hash end end CACHE = Panko::Cache.new end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
panko_serializer-0.1.4 | lib/panko/cache.rb |
panko_serializer-0.1.3 | lib/panko/cache.rb |
panko_serializer-0.1.2 | lib/panko/cache.rb |
panko_serializer-0.1.1 | lib/panko/cache.rb |