Class: Java::OrgMozillaJavascript::Context
- Defined in:
- lib/rhino/rhino_ext.rb
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 ...)
219 220 221 222 223 |
# File 'lib/rhino/rhino_ext.rb', line 219 def cache(key) return yield if @cache == false reset_cache! unless @cache fetch(key) || store(key, yield) end |
#disable_cache! ⇒ Object
209 210 211 |
# File 'lib/rhino/rhino_ext.rb', line 209 def disable_cache! @cache = false end |
#enable_cache! ⇒ Object
205 206 207 |
# File 'lib/rhino/rhino_ext.rb', line 205 def enable_cache! @cache = nil unless @cache end |
#reset_cache! ⇒ Object
201 202 203 |
# File 'lib/rhino/rhino_ext.rb', line 201 def reset_cache! @cache = java.util.WeakHashMap.new end |