Comparing version 0.5.5 to 0.5.6
{ | ||
"name": "brink", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./src/brink/node.js", |
@@ -108,2 +108,8 @@ $b( | ||
undirty : function (recursive) { | ||
this.forEach(function (item) { | ||
item.undirty(recursive); | ||
}); | ||
}, | ||
destroy : function (destroyRecords) { | ||
@@ -110,0 +116,0 @@ |
@@ -454,2 +454,65 @@ /*********************************************************************** | ||
/*********************************************************************** | ||
Patches a record, recursively. | ||
@method patch | ||
@param {Boolean} recursive Whather you want to undirty all embedded relationships as well. | ||
@return {Model} | ||
************************************************************************/ | ||
patch : function (obj) { | ||
function updateRecursively (obj2, context) { | ||
var p; | ||
for (p in obj2) { | ||
if (typeof obj2[p] === 'object') { | ||
updateRecursively(obj2[p], context[p]); | ||
continue; | ||
} | ||
set(context, p, obj2[p]); | ||
} | ||
} | ||
updateRecursively(obj, this); | ||
return this; | ||
}, | ||
/*********************************************************************** | ||
Marks all properties as clean. | ||
@method undirty | ||
@param {Boolean} recursive Whather you want to undirty all embedded relationships as well. | ||
@return {Model} | ||
************************************************************************/ | ||
undirty : function (recursive) { | ||
var i, | ||
p, | ||
meta, | ||
desc, | ||
pMeta, | ||
relationships; | ||
set(this, 'dirtyAttributes.content', []); | ||
if (!recursive) { | ||
return this; | ||
} | ||
meta = this.__meta; | ||
relationships = meta.relationships; | ||
i = relationships.length; | ||
while (i--) { | ||
p = relationships[i]; | ||
desc = this.prop(p); | ||
pMeta = desc.meta(); | ||
if (pMeta.options.embedded) { | ||
get(this, p).undirty(true); | ||
} | ||
} | ||
return this; | ||
}, | ||
/*********************************************************************** | ||
Saves any changes to this record to the persistence layer (via the adapter). | ||
@@ -472,4 +535,2 @@ Also adds this record to the store. | ||
if (!isNew && !dirty.length) {return Q.resolve(this);} | ||
set(this, 'isSaving', true); | ||
@@ -489,3 +550,3 @@ | ||
set(self, 'dirtyAttributes.content', []); | ||
self.undirty(true); | ||
set(self, 'isSaving', false); | ||
@@ -523,3 +584,3 @@ set(self, 'isLoaded', true); | ||
if (!!override) { | ||
set(self, 'dirtyAttributes.content', []); | ||
self.undirty(true); | ||
} | ||
@@ -526,0 +587,0 @@ set(self, 'isFetching', false); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1350924
29350