I use a GetClass mixin, but it has some limitations. Specifically, it can't find the class name if the class is nested on an object.
So, (new MyClass).get_class() = 'MyClass' But, (new NameSpace.MyClass).get_class() fails. https://github.com/seanmonstar/monstars.js/blob/master/src/mvc/GetClass.js On Mon, Dec 6, 2010 at 6:45 AM, אריה גלזר <[email protected]> wrote: > IMO you can't. What you can do is > assertTrue(MyClass instanceof MyGenerricClass); > > > On Mon, Dec 6, 2010 at 4:43 PM, ZsZs <[email protected]> wrote: > >> Hi, >> >> I'd like to have the following behavior: >> >> var MyGenericClass = new Class({getClass: function(){ ... }}); >> var myObject = new MyGenericClass(); >> assertEquals( "MyGenericClass", myObject.getClass() ); >> >> How should I implement getClass? >> I tried: >> this.constructor.toString().match( /function (\w+)\(.+/ )[1]; >> which worked for ordinary objects but doesn't works with MooTools >> objects? >> >> Thank you, >> Zsolt >> >> I know I'm too much Java oriented, I'd like to reuse the patters >> worked for me on server side. Sorry. > > > > > -- > Arieh Glazer > אריה גלזר > 052-5348-561 > http://www.arieh.co.il > http://www.link-wd.co.il > >
