Browse files

Reset changes method

  • Loading branch information...
1 parent 27af51a commit e72db08ad0df196ecc3f01f5ebd74156eb52db9a @1602 committed Nov 28, 2011
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/abstract-class.js
  2. 0 test/{perf_test.coffee → performance.coffee}
View
15 lib/abstract-class.js
@@ -394,15 +394,20 @@ AbstractClass.prototype.propertyChanged = function (attr) {
AbstractClass.prototype.reload = function (cb) {
var obj = this.constructor.cache[this.id];
if (obj) {
- Object.keys(obj).forEach(function (k) {
- if (obj.propertyChanged(k)) {
- obj[k] = obj[k + '_was'];
- }
- });
+ obj.reset();
}
this.constructor.find(this.id, cb);
};
+AbstractClass.prototype.reset = function () {
+ var obj = this;
+ Object.keys(obj).forEach(function (k) {
+ if (obj.propertyChanged(k)) {
+ obj[k] = obj[k + '_was'];
+ }
+ });
+};
+
// relations
AbstractClass.hasMany = function (anotherClass, params) {
var methodName = params.as; // or pluralize(anotherClass.modelName)
View
0 test/perf_test.coffee → test/performance.coffee
File renamed without changes.

0 comments on commit e72db08

Please sign in to comment.