From: dsc Date: Thu, 12 Apr 2012 20:13:04 +0000 (-0700) Subject: Adds Backbone Base docs. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=53ff4fd7661b49facffbda7f0711ff03f0c5f5f4;p=limn.git Adds Backbone Base docs. --- 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='') ->