Commits

Kenneth Jørgensen committed 4fcdb60

Added isEmpty methods to Map and Collection. Fixed default values in Model.

  • Participants
  • Parent commits de48e80

Comments (0)

Files changed (5)

File CHANGELOG.md

 * *Feature:* Removed `Models` default recursive JSON serialization.
 * *Feature:* Implemented default functions in `Model`.
 * *Fix:* Added automatic unbinding of the `Rivets.View` instance in `RivetsHelper`.
+* *Fix:* `Model` never applied its default values.
 
 ## 0.1.1 (2013-06-27)
 

File src/Collection.coffee

 	size: (obj) ->
 		return @_items.length
 
+	# Returns true if the collection is empty.
+	isEmpty: ->
+		return @size() is 0
+
 	# Iterator.
 	each: (fn) ->
 		for entry in @_items

File src/Map.coffee

 		return @
 
 	# Returns the number of items in the map.
-	length: ->
+	size: ->
 		return @_items.length
 
+	# Returns true if the map is empty.
+	isEmpty: ->
+		return @size() is 0
+
 	# Returns a JSON representation of the `Map`.
 	# This will return an object with string-representations of the key objects as the index,
 	# and the value will be an object in the form `{key:*key*, value:*value*}`.

File src/Model.coffee

 			# Execute default function.
 			if _.isFunction val
 				values[key] = val.apply values
+			else
+				values[key] = val
 		return values
 
 	# ID getter/setter.

File src/helpers/RivetsHelper.coffee

 		data = convertData view.model()
 		# Bind.
 		if @rivetsView
-			console.log "clearing old rivets view"
 			@rivetsView.unbind()
 		@rivetsView = Rivets.bind view.element(), data