Skip to content

Commit

Permalink
Fixes bug when creating Models without all data (#69)
Browse files Browse the repository at this point in the history
Getters/setters for properties would not be correctly defined
  • Loading branch information
dresende committed Mar 11, 2013
1 parent 6ae390a commit 77641a8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Instance.js
Expand Up @@ -236,6 +236,12 @@ function Instance(opts) {
addInstanceProperty(opts.id);
}

for (var k in opts.properties) {
if (opts.properties.hasOwnProperty(k) && !opts.data.hasOwnProperty(k) && k != opts.id) {
opts.data[k] = null;
}
}

for (var k in opts.data) {
if (!opts.data.hasOwnProperty(k)) continue;
if (!opts.properties.hasOwnProperty(k) && k != opts.id && opts.association_properties.indexOf(k) == -1) {
Expand Down

0 comments on commit 77641a8

Please sign in to comment.