Skip to content

Commit

Permalink
fix(hooks): replace .bind with .call
Browse files Browse the repository at this point in the history
.bind is having issues in node 4.x, and since using .call instead
  • Loading branch information
thetutlage committed Feb 29, 2016
1 parent 1de6e5d commit fa3ac36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"mysql": "^2.10.2",
"semantic-release": "^4.3.5",
"sqlite3": "^3.1.1",
"standard": "^6.0.5",
"semantic-release": "^4.3.5"
"standard": "^6.0.5"
},
"config": {
"commitizen": {
Expand Down
6 changes: 3 additions & 3 deletions src/Lucid/Model/Mixins/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Hooks.composeHooks = function (scope, hooks) {
Hooks.executeInsertHooks = function * (scope, insertHandler) {
let handlerResult = null
const insertHandlerWrapper = function * (next) {
handlerResult = yield insertHandler.bind(this)
handlerResult = yield insertHandler.call(this)
yield next
}
const hooksChain = this.getHooks('Create', insertHandlerWrapper)
Expand All @@ -102,7 +102,7 @@ Hooks.executeInsertHooks = function * (scope, insertHandler) {
Hooks.executeUpdateHooks = function * (scope, updateHandler) {
let handlerResult = null
const updateHandlerWrapper = function * (next) {
handlerResult = yield updateHandler.bind(this)
handlerResult = yield updateHandler.call(this)
yield next
}
const hooksChain = this.getHooks('Update', updateHandlerWrapper)
Expand All @@ -125,7 +125,7 @@ Hooks.executeUpdateHooks = function * (scope, updateHandler) {
Hooks.executeDeleteHooks = function * (scope, deleteHandler) {
let handlerResult = null
const deleteHandlerWrapper = function * (next) {
handlerResult = yield deleteHandler.bind(this)
handlerResult = yield deleteHandler.call(this)
yield next
}
const hooksChain = this.getHooks('Delete', deleteHandlerWrapper)
Expand Down
3 changes: 2 additions & 1 deletion test/unit/lucid.relations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ describe('Relations', function () {
yield relationFixtures.truncate(Database, 'profiles')
})

it('should be able to save related model instance', function * () {
it('should be able to save related model instance', function * (done) {
class Account extends Model {
}
class Supplier extends Model {
Expand All @@ -718,6 +718,7 @@ describe('Relations', function () {
expect(account.supplier_id).to.equal(supplier.id)
yield relationFixtures.truncate(Database, 'suppliers')
yield relationFixtures.truncate(Database, 'accounts')
done()
})

it('should throw an when save object is not an instance of related model', function * () {
Expand Down

0 comments on commit fa3ac36

Please sign in to comment.