Created
November 26, 2009 14:36
-
-
Save olistik/243489 to your computer and use it in GitHub Desktop.
Method name in every method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.ruby-forum.com/topic/75258#116892 | |
# you could eventually put this in your rails config/environment.rb | |
module Kernel | |
private | |
def this_method | |
caller[0] =~ /`([^']*)'/ and $1 | |
end | |
end | |
def my_method | |
puts "Hello! My name is #{this_method}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment