Class: Mutant::Cache

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Mutable
Defined in:
lib/mutant/cache.rb

Overview

An AST cache

Instance Method Summary collapse

Constructor Details

#initializeundefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object



11
12
13
# File 'lib/mutant/cache.rb', line 11

def initialize
  @cache = {}
end

Instance Method Details

#parse(path) ⇒ AST::Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Root node parsed from file

Parameters:

  • path (#to_s)

Returns:

  • (AST::Node)


22
23
24
25
26
# File 'lib/mutant/cache.rb', line 22

def parse(path)
  @cache.fetch(path) do
    @cache[path] = Parser::CurrentRuby.parse(File.read(path))
  end
end