class Rnfse::CallChain

Public Class Methods

caller_method(depth=1) click to toggle source
# File lib/rnfse/call_chain.rb, line 4
def self.caller_method(depth=1)
  parse_caller(caller(depth+1).first).last
end

Private Class Methods

parse_caller(at) click to toggle source

Stolen from ActionMailer with a tweek, where this was used but was not made reusable

# File lib/rnfse/call_chain.rb, line 12
def self.parse_caller(at)
  if /^(.+?):(\d+)(?::in `((block in )?(.*))')?/ =~ at
    file   = Regexp.last_match[1]
    line   = Regexp.last_match[2].to_i
    method = Regexp.last_match[5]
    [file, line, method]
  end
end