BaseBackboneMixin = exports.BaseBackboneMixin =
+
initialize: ->
@__apply_bind__()
self.unwait(); fn ...
+ getClassName: ->
+ "#{@..name or @..displayName}"
+
+ toString: ->
+ "#{@getClassName()}()"
+
mixinBase = exports.mixinBase = (body) ->
_.clone(BaseBackboneMixin) import body
* Like `.toJSON()` in that it should return a plain object with no functions,
* but for the purpose of `.toKV()`, allowing you to customize the values
* included and keys used.
+ *
+ * @param {Object} [opts={}] Options:
+ * @param {Boolean} [opts.keepFunctions=false] If false, functions will be omitted from the result.
* @returns {Object}
*/
- toKVPairs: ->
+ toKVPairs: (opts={}) ->
+ opts = {-keepFunctions, ...opts}
kvo = _.collapseObject @toJSON()
for k, v in kvo
- kvo[k] = @serialize v
+ kvo[k] = @serialize v if opts.keepFunctions or typeof v is not 'function'
kvo
/**
toURL: ->
"?#{@toKV ...}"
- toString: -> "#{@..name or @..displayName}(cid=#{@cid}, id=#{@id})"
+ toString: ->
+ "#{@getClassName()}(cid=#{@cid}, id=#{@id})"
# Class Methods
toURL: (item_delim='&', kv_delim='=') ->
"?#{@toKV ...}"
- toString: -> "#{@..name or @..displayName}(length=#{@length})"
+ toString: ->
+ modelIds = @models
+ .map -> "\"#{it.id ? it.cid}\""
+ .join ', '
+ "#{@getClassName()}[#{@length}](#modelIds)"
# }}}
# @$el.appendTo parent if parent?.length
# this
- toString : -> "#{@..name or @..displayName}(model=#{@model})"
+ toString : ->
+ "#{@getClassName()}(model=#{@model})"
# Proxy model methods