Skip to content

Commit

Permalink
Allows user to pass an object to extendsTo.setAccessor instead of an …
Browse files Browse the repository at this point in the history
…instance (detected via #250)
  • Loading branch information
dresende committed Jul 30, 2013
1 parent b888d9e commit bea9c0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Associations/Extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function extendInstance(Model, Instance, Driver, association, opts) {

var fields = Object.keys(association.field);

if (!Extension.isInstance) {
Extension = new association.model(Extension);
}

for (var i = 0; i < Model.id.length; i++) {
Extension[fields[i]] = Instance[Model.id[i]];
}
Expand Down
1 change: 1 addition & 0 deletions lib/Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function Instance(Model, opts) {
};
var afterSave = function (cb, create, err) {
emitEvent("save", err, instance);

if (create) {
Hook.trigger(instance, opts.hooks.afterCreate, !err);
}
Expand Down

0 comments on commit bea9c0b

Please sign in to comment.