Module: MethodSource::SourceLocation::MethodExtensions

Includes:
ReeSourceLocation
Included in:
Method
Defined in:
lib/method_source/source_location.rb

Instance Method Summary (collapse)

Instance Method Details

- (Array) source_location

Return the source location of a method for Ruby 1.8.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/method_source/source_location.rb', line 20

def source_location
  if @file.nil?
    args =[*(1..(arity<-1 ? -arity-1 : arity ))]

    set_trace_func method(:trace_func).to_proc
    call(*args) rescue nil
    set_trace_func nil
    @file = File.expand_path(@file) if @file && File.exist?(File.expand_path(@file))
  end
  return [@file, @line] if File.exist?(@file.to_s)
end