Class: Prawn::ThreadLocalCache

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/utilities.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadLocalCache

Returns a new instance of ThreadLocalCache.



34
35
36
# File 'lib/prawn/utilities.rb', line 34

def initialize
  @cache_id = "cache_#{self.object_id}".to_sym
end

Instance Method Details

#[](key) ⇒ Object



37
38
39
# File 'lib/prawn/utilities.rb', line 37

def [](key)
  (Thread.current[@cache_id] ||= {})[key]
end

#[]=(key, value) ⇒ Object



40
41
42
# File 'lib/prawn/utilities.rb', line 40

def []=(key,value)
  (Thread.current[@cache_id] ||= {})[key] = value
end