Get The Name Of The Current Method In Ruby
Join the DZone community and get the full member experience.
Join For FreeFound 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'
Opinions expressed by DZone contributors are their own.
Comments