Skip to content

Commit

Permalink
JSCS code cleanup + fix line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
blah238 committed Sep 19, 2016
1 parent b8364b2 commit f05ca99
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
22 changes: 12 additions & 10 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ Manager.prototype.isCollection = function(model) {
Manager.prototype.save = function(model, properties, options) {
if (this.isModel(model)) {
return this.saveModel(model, properties, options);
} else if (this.isCollection(model)) {
}

if (this.isCollection(model)) {
return this.saveCollection(model, properties, options);
}

Expand Down Expand Up @@ -218,7 +220,9 @@ Manager.prototype.saveModel = function(model, properties, options) {
Manager.prototype.set = function(model, properties, options) {
if (this.isModel(model)) {
return this.setModel(model, properties, options);
} else if (this.isCollection(model)) {
}

if (this.isCollection(model)) {
return this.setCollection(model, properties, options);
}

Expand Down Expand Up @@ -329,22 +333,20 @@ Manager.prototype.setHasOne = function(model, key, value, relation, options) {
var existing = Target.forge(model.related(key).attributes);
var target = Target.forge(value);
var fk = relation.relatedData.foreignKey;

if (value !== null) {
if (existing.get(fk)) {
existing.set(fk, null);
}
else{
} else {
target.set(fk, model.id);
return target.save();
}

return existing.save()
.then(function(){
target.set(fk, model.id);
return target.save();

});
.then(function() {
target.set(fk, model.id);
return target.save();
});
}
};

Expand Down
3 changes: 1 addition & 2 deletions test/manager.create.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ describe('manager', function() {
assert.equal('White', color.get('name'), 'Color name should be White');
assert.equal('#fff', color.get('hex_value'), 'Color hex_value should be #fff');
});
} else {
throw err;
}
throw err;
});
});
});
Expand Down
3 changes: 1 addition & 2 deletions test/manager.save.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ describe('manager', function() {
assert.equal(1, car.get('quantity', 'Car should have quantity 1, got: ' + car.get('quantity')));
assert.equal(2, car.related('features').length, 'Car should have 2 existing features');
});
} else {
throw err;
}
throw err;
});
});

Expand Down

0 comments on commit f05ca99

Please sign in to comment.