Skip to content

Instantly share code, notes, and snippets.

@olistik
Created November 26, 2009 14:36
Show Gist options
  • Save olistik/243489 to your computer and use it in GitHub Desktop.
Save olistik/243489 to your computer and use it in GitHub Desktop.
Method name in every method
# 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