From 53ff4fd7661b49facffbda7f0711ff03f0c5f5f4 Mon Sep 17 00:00:00 2001 From: dsc Date: Thu, 12 Apr 2012 13:13:04 -0700 Subject: [PATCH] Adds Backbone Base docs. --- lib/base.co | 7 +++++-- lib/util/underscore/kv.co | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/base.co b/lib/base.co index 225ea6e..cc62b1f 100644 --- a/lib/base.co +++ b/lib/base.co @@ -75,8 +75,11 @@ BaseModel = exports.BaseModel = Backbone.Model.extend do # {{{ */ toKVPairs: -> kvo = _.collapseObject @toJSON() - for k, v in kvo - kvo[k] = @serialize v + if v and _.isObject v + for k, v in kvo + kvo[k] = @serialize v unless typeof v is 'function' + else + @serialize v kvo /** diff --git a/lib/util/underscore/kv.co b/lib/util/underscore/kv.co index fdc31ba..4eb5389 100644 --- a/lib/util/underscore/kv.co +++ b/lib/util/underscore/kv.co @@ -32,7 +32,7 @@ _kv = do {} /** - * Copies and flattens any sub-objects into namespaced keys on the parent object, such + * Copies and flattens a tree of sub-objects into namespaced keys on the parent object, such * that `{ "foo":{ "bar":1 } }` becomes `{ "foo.bar":1 }`. */ collapseObject: (obj, parent={}, prefix='') -> -- 1.7.0.4