Browse files

Added a few comments

  • Loading branch information...
1 parent 7e82ff2 commit c3494c085c1347bc160d5beb0a5c34346a9a8cab @nathanmacinnes committed Aug 4, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/pretendr.js
View
7 lib/pretendr.js
@@ -33,11 +33,16 @@ makeBaseObj = function (descriptor, mock) {
setReturnValue,
setTemplate;
+ // check we haven't already created the pretendr object to prevent
+ // infinite recursion
for (i = 0; i < ins.length; i++) {
if (descriptor === ins[i]) {
+ // if we have, return the output which corresponds to this
+ // input
return outs[i];
}
}
+ // if not, create new inputs and outputs
indexNum = ins.length;
ins.push(descriptor);
outs[indexNum] = baseObj;
@@ -64,6 +69,8 @@ makeBaseObj = function (descriptor, mock) {
};
baseObj.applyAttributesTo = function (other) {
var i;
+ // The attribute properties conveniently have the same name as the
+ // pretendr methods, so just loop through them.
for (i in attributes) {
if (attributes.hasOwnProperty(i)) {
other[i](attributes[i]);

0 comments on commit c3494c0

Please sign in to comment.