Module: Treat::Helpers::Object::CallerMethod

Defined in:
lib/treat/helpers/object.rb

Overview

Allow introspection onto what method called another one at runtime (useful for debugging).

Constant Summary collapse

CMPattern =

Pattern to match method from trace.

/^(.+?):(\d+)(?::in `(.*)')?/

Instance Method Summary collapse

Instance Method Details

#caller_method(n = 3) ⇒ Object

Return the name of the method that called the method that calls this method.



11
12
13
14
15
16
# File 'lib/treat/helpers/object.rb', line 11

def caller_method(n = 3)
  at = caller(n).first
  CMPattern =~ at
  Regexp.last_match[3].
  gsub('block in ', '').intern
end