Enumerate all classes

11 views
Skip to first unread message

Victor

unread,
Aug 9, 2012, 6:19:43 AM8/9/12
to prototype-s...@googlegroups.com
Hello!

I need some more ideas how to enumerate all classes - find at runtime (in browser) all classes created with Class.create(). My initial approach:

function enumerateClasses() {
  for (var p in window) {
    var c = window[p];
    if (Object.isFunction(c) &&
    !Object.isUndefined(c.superclass) &&
    !Object.isUndefined(c.subclasses) &&
    c.prototype &&
    c.prototype.initialize) {
      console.log(p, c);
    }
  }
}

but this works only for classes like Hash and Template, and doesn't work for classes in a namespace like Ajax.Request.
Reply all
Reply to author
Forward
0 new messages