Skip to content

Commit

Permalink
Add a toObj() method to the ModelItemConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Techwraith committed Mar 14, 2012
1 parent 22f12dd commit 6aca9e1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/model/index.js
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 6aca9e1

Please sign in to comment.