> 2006/4/21, Philip Hallstrom <ruby / philip.pjkh.com>:
>> Hi all -
>>
>> Given the following bit of code, I'd like it to spit out "Cat" followed by
>> "Dog", but what I get now is "Object" twice.
>>
>> ---------------------------------------------------------------
>> class Animal
>>      def self.what_am_i
>>          self.class
>>      end
>> end
>>
>> class Cat < Animal
>> end
>>
>> class Dog < Animal
>> end
>>
>> puts Cat.what_am_i
>> puts Dog.what_am_i
>> ---------------------------------------------------------------
>>
>> The closest I can get is self.object_id which prints out different ID's,
>> but I'd really like the name if I can get it...
>
> Let me get this straight: you have a class object and you want a
> method that returns this class object? The code that does what you
> want is this:
>
> def self.what_am_i?
>  self
> end
>
> But this seems a rather weird thing to do...

:-)  This is just the simplest example I could think of.  The actual 
method in the parent class is responsible for storing "stuff" in memcache 
and I want to dynamically set the key used to store it to the class name 
and the primary key.  That way I won't have to worry about collisions.

For the archives, seems that

def self.what_am_i
 	put self
 	put self.name
end

will do exactly what I want (return the name of the calling class)

Thanks all!

-philip