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



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

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.

Return node for file

Parameters:

  • path (#to_s)

Returns:

  • (AST::Node)


24
25
26
27
28
# File 'lib/mutant/cache.rb', line 24

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