Never been to DZone Snippets before?

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

About this user

JavaScript Wizard

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Get the name of the current method in Ruby

Found at http://nubyonrails.com/articles/2006/08/04/seattle-rbbq

def method_name
  if  /`(.*)'/.match(caller.first)
    return $1
  end
  nil
end

def blah
  puts method_name
end

blah  # => 'blah'
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS