From 6aca9e100460dab1389b67d106f67aa3ac64bf6d Mon Sep 17 00:00:00 2001 From: Techwraith Date: Tue, 13 Mar 2012 20:50:42 -0700 Subject: [PATCH] Add a toObj() method to the ModelItemConstructor --- lib/model/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/model/index.js b/lib/model/index.js index 375cb8b2..03bff2aa 100644 --- a/lib/model/index.js +++ b/lib/model/index.js @@ -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 = {};