From: Ryan Tarpine Date: 2001-09-16T01:18:46+09:00 Subject: [ruby-talk:21225] Class of caller Is there a way to get the class of the object that called a certain method? This could be used to make friend classes like C++, with the added benefit that if there are multiple friends, each will only have access to their required methods, not all protected methods. class Foo def onlyfriends if @friendclasses["onlyfriends"].include? callerclass ... end end end It could even be extended to allow subclasses of friends to be allowed as well, such as class Foo def onlyfriends if @friendclasses["onlyfriends"].find { |f| callerclass.kind_of? f } ... end end end This could be hacked by the caller passing self and the method checking its class, but a callerclass-type method seems better. Is there anything like this currently? -- self.instance_of? RyanTarpine # => true