Permalink
Browse files

Releasing 0.1.3

  • Loading branch information...
1 parent b575dcc commit 9056f5e0ba9beb4ba0f06cdc5fbd2186c6cdec5d @iros iros committed May 23, 2012
View
@@ -1 +1 @@
-2012/05/04 07:37
+2012/05/23 11:14
@@ -1,5 +1,5 @@
/**
-* Miso.Dataset - v0.1.2 - 5/4/2012
+* Miso.Dataset - v0.1.3 - 5/23/2012
* http://github.com/misoproject/dataset
* Copyright (c) 2012 Alex Graul, Irene Ros;
* Dual Licensed: MIT, GPL
@@ -1640,7 +1640,7 @@ Version 0.0.1.2
this.importer.fetch({
success: _.bind(function( data ) {
- this.apply( data );
+ this._apply( data );
// if a comparator was defined, sort the data
if (this.comparator) {
@@ -1744,7 +1744,7 @@ Version 0.0.1.2
},
//Takes a dataset and some data and applies one to the other
- apply : function( data ) {
+ _apply : function( data ) {
var parsed = this.parser.parse( data );
@@ -1949,36 +1949,45 @@ Version 0.0.1.2
*/
update : function(filter, newProperties, options) {
- var newKeys = _.keys(newProperties), deltas = [];
+ var newKeys, deltas = [];
var updateRow = _.bind(function(row, rowIndex) {
- var c;
+ var c, props;
+
+ if (_.isFunction(newProperties)) {
+ props = newProperties.apply(this, [row]);
+ } else {
+ props = newProperties;
+ }
+
+ newKeys = _.keys(props);
+
_.each(newKeys, function(columnName) {
c = this.column(columnName);
// test if the value passes the type test
var Type = Miso.types[c.type];
if (Type) {
- if (Miso.typeOf(newProperties[c.name], c) === c.type) {
+ if (Type.test(props[c.name], c)) {
// do we have a before filter on the column? If so, apply it
if (!_.isUndefined(c.before)) {
- newProperties[c.name] = c.before(newProperties[c.name]);
+ props[c.name] = c.before(props[c.name]);
}
// coerce it.
- newProperties[c.name] = Type.coerce(newProperties[c.name], c);
+ props[c.name] = Type.coerce(props[c.name], c);
} else {
- throw("incorrect value '" + newProperties[c.name] +
- "' of type " + Miso.typeOf(newProperties[c.name], c) +
+ throw("incorrect value '" + props[c.name] +
+ "' of type " + Miso.typeOf(props[c.name], c) +
" passed to column with type " + c.type);
}
}
- c.data[rowIndex] = newProperties[c.name];
+ c.data[rowIndex] = props[c.name];
}, this);
- deltas.push( { _id : row._id, old : row, changed : newProperties } );
+ deltas.push( { _id : row._id, old : row, changed : props } );
}, this);
// do we just have a single id? array it up.
Oops, something went wrong.

0 comments on commit 9056f5e

Please sign in to comment.