Get the name of the current method in Ruby
def method_name if /`(.*)'/.match(caller.first) return $1 end nil end def blah puts method_name end blah # => 'blah'
DZone Snippets > jswizard > meta
11380 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
def method_name if /`(.*)'/.match(caller.first) return $1 end nil end def blah puts method_name end blah # => 'blah'