From: "Iñaki Baz Castillo" Date: 2009-04-01T04:55:29+09:00 Subject: Re: Getting the current module(s), class name and method in Ruby 1.9 El Martes 31 Marzo 2009, Iñaki Baz Castillo escribió: > El Martes 31 Marzo 2009, Iñaki Baz Castillo escribió: > > Fantastic! Thanks a lot. > > If somebody is interested, I've implemented the above code adding Class > methods logging feature: > > ---------------- > module Kernel > > def this_method > if self.class == Class > "#{self.to_s}.#{caller[0][/`(.*)'/, 1]}" > else > "#{self.class}##{caller[0][/`(.*)'/, 1]}" > end > end > private :this_method > > end > > > > module MM > class AA > def self.class_method > puts this_method > end > > def instance_method > puts this_method > end > end > end > > > MM::AA.class_method > => "MM::AA.class_method" > > MM::AA.new.instance_method > => "MM::AA#instance_method" > ---------------- Hi again. Wouldn't make sense to have such features in Ruby core instead of having to parse "caller[0][/`(.*)'/, 1]" and so? Is it possible to open a feature request for it? or is it too late for such wishes in 1.9? Thanks. -- Iñaki Baz Castillo