Class: Java::OrgMozillaJavascript::Context
- Defined in:
- lib/rhino/rhino_ext.rb
Constant Summary collapse
- CACHE =
java.util.WeakHashMap.new
Instance Method Summary collapse
-
#cache(key) ⇒ Object
Support for caching JS data per context.
- #disable_cache! ⇒ Object
- #enable_cache! ⇒ Object
- #reset_cache! ⇒ Object
Instance Method Details
#cache(key) ⇒ Object
Support for caching JS data per context. e.g. to get === comparison’s working …
NOTE: the cache only works correctly for keys following Java identity !
(implementing #equals & #hashCode e.g. RubyStrings will work ...)
249 250 251 252 253 |
# File 'lib/rhino/rhino_ext.rb', line 249 def cache(key) return yield if (cache = CACHE[self]) == false cache = reset_cache! unless cache fetch(key, cache) || store(key, yield, cache) end |
#disable_cache! ⇒ Object
239 240 241 |
# File 'lib/rhino/rhino_ext.rb', line 239 def disable_cache! CACHE[self] = false end |