Skip to content

Commit

Permalink
Add an id#ancestors() helper function, to walk up the inheritance chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Aug 26, 2011
1 parent b3cee63 commit 288aa25
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions id.js
Expand Up @@ -122,6 +122,20 @@ proto.setClass = function setClass (newClass) {
return exports._wrapClass(core.object_setClass(this.pointer, newClass.pointer));
}

/**
* Walks up the inheritance chain and returns an Array of Strings of
* superclasses.
*/
proto.ancestors = function ancestors () {
var rtn = []
, c = this.getClass()
while (c) {
rtn.push(c.getName())
c = c.getSuperclass()
}
return rtn
}

/**
* Returns an Array of Strings of the names of methods that the current object
* will respond to. This function can iterate through the object's superclasses
Expand Down

0 comments on commit 288aa25

Please sign in to comment.