Skip to content

Commit

Permalink
Merge branch 'master' of github.com:LearnBoost/mongoose
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Mar 5, 2011
2 parents fb3dd61 + 5dbad69 commit b52efe8
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/mongoose/document.js
Expand Up @@ -565,29 +565,29 @@ Document.registerHooks = function () {
this.prototype[arguments[i]] = (function(methodName, oldFn){
return function () {
var self = this
, args = arguments;
, args = arguments
, pres = this.pres[methodName];

if (!pres) return oldFn.apply(this, args);

function error (err){
var lastArg = args[args.length-1];
if (typeof lastArg == 'function')
lastArg.call(self, err);
}
var pres = this.pres[methodName];
if (!pres) return oldFn.apply(this, args);

var pres = this.pres[methodName]
, chain = pres.serial.map(function (fn, i) {
return function (err) {
if (arguments.callee._hookCalled) return;
var chain = pres.serial.map(function (fn, i) {
return function (err) {
if (arguments.callee._hookCalled) return;

if (err instanceof Error)
error(err);
else
fn.call(self, chain[i+1] || parallel);
if (err instanceof Error)
error(err);
else
fn.call(self, chain[i+1] || parallel);

arguments.callee._hookCalled = true;
};
});
arguments.callee._hookCalled = true;
};
});

chain.length ? chain[0]() : parallel();

Expand Down

0 comments on commit b52efe8

Please sign in to comment.