Re: using the current method name within current method
blade.nagaokaut.ac.jp
"Aleks Kissinger wrote:
> Depending on how you feel about mucking with core ruby types, a method
> like this one seems like a decent candidate for mixing in to Object.
>
> class Object
> def this_method
> caller[0]=~/`(.*?)'/
> $1
> end
> end
These methods are typically put into Kernel and made private. Also, you
don't check whether the RX actually matches. I'd also prefer to change
the RX to a more efficient one. So that would give
module Kernel
private
def this_method
caller[0] =~ /`([^']*)'/ and $1
end
end
Kind regards
robert"
#Ruby #code #core #dynamic #pub
Collect and share the web
Get started for free