@@ -32,14 +32,21 @@ Model = this.Model = Class({
32
32
_diff : function ( ) {
33
33
var keys = Object . keys ( this . __doc ) ,
34
34
casters = Object . keys ( this . _casters ) ,
35
+ arrs = Object . keys ( this . _arrays ) ,
35
36
exclude = { } ;
36
37
37
38
for ( var i = 0 , l = casters . length ; i < l ; i ++ ) {
38
39
this . _partials [ casters [ i ] ] = JSON . stringify ( this . _get ( casters [ i ] ) ) ;
39
40
}
40
41
41
42
for ( var i = 0 , l = keys . length ; i < l ; i ++ ) {
42
- this . _partials [ keys [ i ] ] = JSON . stringify ( this . __doc [ keys [ i ] ] ) ;
43
+ this . _partials [ keys [ i ] ] = JSON . stringify ( this . __doc [ keys [ i ] ] ) ;
44
+ }
45
+
46
+ for ( var i = 0 , l = arrs . length ; i < l ; i ++ ) {
47
+ if ( ! this . _partials [ arrs [ i ] ] ) {
48
+ this . _partials [ arrs [ i ] ] = JSON . stringify ( this . __doc [ keys [ i ] ] ) ;
49
+ }
43
50
}
44
51
} ,
45
52
@@ -51,9 +58,10 @@ Model = this.Model = Class({
51
58
_parent = _parent || this ;
52
59
var keys = Object . getOwnPropertyNames ( doc ) ;
53
60
keys . forEach ( function ( i ) {
54
- if ( _parent [ i ] && typeof ( _parent [ i ] == 'object' ) && ! ( _parent [ i ] instanceof Array ) ) this . merge ( doc [ i ] , _parent [ i ] ) ;
61
+ if ( _parent [ i ] && typeof _parent [ i ] == 'object' && ! ( _parent [ i ] instanceof Array ) ) this . merge ( doc [ i ] , _parent [ i ] ) ;
55
62
else _parent [ i ] = doc [ i ] ;
56
63
} , this ) ;
64
+ return this ;
57
65
} ,
58
66
59
67
_set : function ( path , value , internal ) {
@@ -296,7 +304,8 @@ _define = function(proto, key, value){
296
304
if ( Object . prototype . toString . call ( prop ) == '[object Object]' ) {
297
305
for ( field in prop ) {
298
306
if ( prop [ field ] instanceof Array ) {
299
- _arr [ ( path ? path + '.' : '' ) + field ] = true ;
307
+ p = ( path ? path + '.' : '' ) + field ;
308
+ _arr [ p ] = true ;
300
309
if ( ! prop [ field ] . length ) _ret [ field ] = [ ] ;
301
310
else if ( prop [ field ] [ 0 ] instanceof Array ) _ret [ field ] = [ ] ;
302
311
else _ret [ field ] = _compileProperties ( prop [ field ] , _arr , p ) ;
0 commit comments