Class: Prawn::ThreadLocalCache
- Inherits:
-
Object
- Object
- Prawn::ThreadLocalCache
- Defined in:
- lib/prawn/utilities.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ ThreadLocalCache
constructor
A new instance of ThreadLocalCache.
Constructor Details
#initialize ⇒ ThreadLocalCache
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 |