Class: EnumIsh::DictionaryCache

Inherits:
Object
  • Object
show all
Defined in:
lib/enum_ish/dictionary_cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ DictionaryCache

Returns a new instance of DictionaryCache.



5
6
7
# File 'lib/enum_ish/dictionary_cache.rb', line 5

def initialize(app)
  @app = app
end

Class Method Details

.cacheObject



19
20
21
# File 'lib/enum_ish/dictionary_cache.rb', line 19

def cache
  Thread.current[cache_key]
end

.enableObject



23
24
25
26
27
28
# File 'lib/enum_ish/dictionary_cache.rb', line 23

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

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/enum_ish/dictionary_cache.rb', line 9

def call(env)
  EnumIsh::DictionaryCache.enable do
    @app.call(env)
  end
end