Sha256: e139dd935d4ea6ee9f46bdfd42126c21636790d8ca02fed03f6f7846d532f7bc

Contents?: true

Size: 538 Bytes

Versions: 4

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module EnumIsh
  class DictionaryCache
    def initialize(app)
      @app = app
    end
  
    def call(env)
      EnumIsh::DictionaryCache.enable do
        @app.call(env)
      end
    end

    class << self
      class_attribute :cache_key
      self.cache_key = :_enum_ish_dictionary_cache

      def cache
        Thread.current[cache_key]
      end

      def enable
        Thread.current[cache_key] = {}
        yield
      ensure
        Thread.current[cache_key] = nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enum_ish-1.6.3 lib/enum_ish/dictionary_cache.rb
enum_ish-1.6.2 lib/enum_ish/dictionary_cache.rb
enum_ish-1.6.1 lib/enum_ish/dictionary_cache.rb
enum_ish-1.6.0 lib/enum_ish/dictionary_cache.rb