Permalink
Browse files

Add a toObj() method to the ModelItemConstructor

  • Loading branch information...
1 parent 22f12dd commit 6aca9e100460dab1389b67d106f67aa3ac64bf6d Techwraith committed Mar 14, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/model/index.js
View
@@ -123,6 +123,22 @@ utils.mixin(model, new (function () {
geddy.model.updateItem(this, params, opts || {});
};
+ /**
+ @name ModelBase#toObj
+ @public
+ @function
+ @description Returns an object with just the properties
+ and values of the model instance
+ */
+ this.toObj = function () {
+ var obj
+ , props = this.properties;
+ obj.id = this.id;
+ for (var p in props) {
+ obj[props[p]] = this[props[p]];
+ }
+ return obj;
+ }
this.toString = function () {
var obj = {};

0 comments on commit 6aca9e1

Please sign in to comment.