Class: Riml::RewrittenASTCache
- Inherits:
-
Object
- Object
- Riml::RewrittenASTCache
- Defined in:
- lib/riml/rewritten_ast_cache.rb
Instance Method Summary collapse
- #[](filename) ⇒ Object
- #clear ⇒ Object
- #fetch(filename) ⇒ Object
- #fetch_classes_registered(ast) ⇒ Object
-
#initialize ⇒ RewrittenASTCache
constructor
A new instance of RewrittenASTCache.
- #save_classes_registered(ast, class_diff) ⇒ Object
Constructor Details
#initialize ⇒ RewrittenASTCache
Returns a new instance of RewrittenASTCache.
3 4 5 6 |
# File 'lib/riml/rewritten_ast_cache.rb', line 3 def initialize @cache = {} @ast_classes_registered_cache = {} end |
Instance Method Details
#[](filename) ⇒ Object
8 9 10 |
# File 'lib/riml/rewritten_ast_cache.rb', line 8 def [](filename) @cache[filename] end |
#clear ⇒ Object
18 19 20 21 |
# File 'lib/riml/rewritten_ast_cache.rb', line 18 def clear @cache.clear @ast_classes_registered_cache.clear end |
#fetch(filename) ⇒ Object
12 13 14 15 16 |
# File 'lib/riml/rewritten_ast_cache.rb', line 12 def fetch(filename) ast = @cache[filename] return ast if ast @cache[filename] = yield end |
#fetch_classes_registered(ast) ⇒ Object
27 28 29 |
# File 'lib/riml/rewritten_ast_cache.rb', line 27 def fetch_classes_registered(ast) @ast_classes_registered_cache[ast.object_id] || {} end |
#save_classes_registered(ast, class_diff) ⇒ Object
23 24 25 |
# File 'lib/riml/rewritten_ast_cache.rb', line 23 def save_classes_registered(ast, class_diff) @ast_classes_registered_cache[ast.object_id] = class_diff end |