Repository: feathersjs/feathers-hooks (js)

Issue:
feathers-hooks is changing the scope of makeWrapper()
When using feathers-hooks, the scope of the [makeWrapper()](https://github.com/feathersjs/feathers/blob/master/lib/mixins/promise.js#L4) function is the global node object.  Since that same scope is passed to the `feathers-mongodb` service, it causes an error [here](https://github.com/feathersjs/feathers-mongodb/blob/master/lib/mongodb.js#L66) of `TypeError: Cannot call method 'find' of undefined`.  (this.collection is undefined on the global node object).

If I comment out the `users.before()` line in the example code below, the scope of `this` inside makeWrapper() is the service with its methods.

I've tested both the latest commit of `feathers-hooks` and the `0.4.0` version from npm.

So far this has only been a problem when using [feathers-mongodb](https://github.com/feathersjs/feathers-mongodb) because of its use of `this` inside the methods.

Here is the simple server.js I'm using to test:
```js
var feathers = require('feathers'),
  fHooks = require('feathers-hooks'),
  mongo = require('mongoskin'),
  fMongo = require('feathers-mongodb'),
	bodyParser = require('body-parser');

var app = feathers()
	.use(feathers.static(__dirname + '/public'))
	.configure(feathers.rest())
	.use(bodyParser())
	.configure(fHooks())
	.configure(feathers.socketio())
	.configure(feathers.errors());

// Synchronous connect to db
var db = mongo.db('mongodb://localhost:27017/feathers-tuts');
var userService = fMongo({collection:db.collection('users')});

// The users endpoint must match the one setup on config.store.
app.use('api/users', userService);
var users = app.service('api/users');
// Dummy hook
function hookMe(hook, next){
	next();
}
users.before({find:[hookMe]});

// Start the server.
var port = 8080;
app.listen(port, function() {
  console.log('Feathers server listening on port ' + port);
});
```

Pull request:
Make sure hooks and service methods keep their context
This pull request makes sure that hooks don't loose the service as the context. Closes #17.

Patch:
diff --git a/lib/commons.js b/lib/commons.js
index 4c7a2c9..fa355a2 100644
--- a/lib/commons.js
+++ b/lib/commons.js
@@ -23,7 +23,7 @@ exports.makeHookFn = function(hook, prev) {
       }
 
       prev.call(this, currentHook);
-    };
+    }.bind(this);
 
     var promise = hook.call(this, hookObject, hookCallback);
 


Test patch:
diff --git a/test/after.test.js b/test/after.test.js
index bae19b3..8504505 100644
--- a/test/after.test.js
+++ b/test/after.test.js
@@ -275,4 +275,34 @@ describe('.after hooks', function() {
       });
     });
   });
+
+  it('after hooks have service as context and keep it in service method (#17)', function(done) {
+    var app = feathers().configure(hooks()).use('/dummy', {
+      number: 42,
+      get: function(id, params, callback) {
+        callback(null, {
+          id: id,
+          number: this.number
+        });
+      }
+    });
+
+    var service = app.service('dummy');
+
+    service.after({
+      get: function(hook, next) {
+        hook.result.test = this.number + 1;
+        next();
+      }
+    });
+
+    service.get(10, {}, function(error, data) {
+      assert.deepEqual(data, {
+        id: 10,
+        number: 42,
+        test: 43
+      });
+      done();
+    });
+  });
 });
diff --git a/test/before.test.js b/test/before.test.js
index d9e72ec..5c03799 100644
--- a/test/before.test.js
+++ b/test/before.test.js
@@ -299,4 +299,35 @@ describe('.before hooks', function() {
       service.get(1, {}, done);
     });
   });
+
+  it('before hooks have service as context and keep it in service method (#17)', function(done) {
+    var app = feathers().configure(hooks()).use('/dummy', {
+      number: 42,
+      get: function(id, params, callback) {
+        callback(null, {
+          id: id,
+          number: this.number,
+          test: params.test
+        });
+      }
+    });
+
+    var service = app.service('dummy');
+
+    service.before({
+      get: function(hook, next) {
+        hook.params.test = this.number + 2;
+        next();
+      }
+    });
+
+    service.get(10, {}, function(error, data) {
+      assert.deepEqual(data, {
+        id: 10,
+        number: 42,
+        test: 44
+      });
+      done();
+    });
+  });
 });