Class: Stackprofiler::RunCodeCache

Inherits:
Object
  • Object
show all
Extended by:
MethodSource::CodeHelpers
Defined in:
lib/stackprofiler/run_code_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ RunCodeCache

Returns a new instance of RunCodeCache.



5
6
7
# File 'lib/stackprofiler/run_code_cache.rb', line 5

def initialize profile
  @profile = profile
end

Instance Method Details

#source_helper(source_location, name = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stackprofiler/run_code_cache.rb', line 9

def source_helper(source_location, name=nil)
  file, line = *source_location
  file_cache = @profile[:files] || []

  if file_cache.include? file
    file_data = @profile[:files][file]
    self.class.expression_at(file_data, line)
  else
    MethodSource::source_helper(source_location, name)
  end
end