Sha256: 7a0375e2b76498e4f0a91c314e64d52418a81c452e190341c5883b3c1ed8ef67

Contents?: true

Size: 500 Bytes

Versions: 6

Compression:

Stored size: 500 Bytes

Contents

module Rnfse

  class CallChain
    def self.caller_method(depth=1)
      parse_caller(caller(depth+1).first).last
    end

    private

    # Stolen from ActionMailer with a tweek,
    # where this was used but was not made reusable
    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
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rnfse-0.6.2 lib/rnfse/call_chain.rb
rnfse-0.6.1 lib/rnfse/call_chain.rb
rnfse-0.6.0 lib/rnfse/call_chain.rb
rnfse-0.5.3 lib/rnfse/call_chain.rb
rnfse-0.5.1 lib/rnfse/call_chain.rb
rnfse-0.5.0 lib/rnfse/call_chain.rb