File tree 3 files changed +8
-13
lines changed
3 files changed +8
-13
lines changed Original file line number Diff line number Diff line change 3
3
this . attributes = Model . Utils . extend ( { } , attributes )
4
4
this . changes = { }
5
5
this . errors = new Model . Errors ( this )
6
- this . uid = [ name , Model . UID . generate ( ) ] . join ( "-" )
6
+ this . uid = Model . UID ( )
7
7
if ( Model . Utils . isFunction ( this . initialize ) ) this . initialize ( )
8
8
this . emit ( "initialize" , this )
9
9
}
Original file line number Diff line number Diff line change 1
- Model . UID = {
2
- counter : 0 ,
1
+ ; ( function ( Model ) {
2
+ var counter = 0
3
3
4
- generate : function ( ) {
5
- return [ new Date ( ) . valueOf ( ) , this . counter ++ ] . join ( "-" )
6
- } ,
7
-
8
- reset : function ( ) {
9
- this . counter = 0
10
- return this
4
+ Model . UID = function ( ) {
5
+ return [ counter ++ , new Date ( ) . valueOf ( ) ] . join ( "-" )
11
6
}
12
- } ;
7
+ } ) ( Model )
Original file line number Diff line number Diff line change 1
1
module ( "Model.UID" )
2
2
3
3
test ( "UIDs shouldn't be the same" , function ( ) {
4
- var uid1 = Model . UID . generate ( )
5
- var uid2 = Model . UID . generate ( )
4
+ var uid1 = Model . UID ( )
5
+ var uid2 = Model . UID ( )
6
6
7
7
ok ( uid1 !== uid2 , uid1 + " shouldn't equal " + uid2 )
8
8
} )
You can’t perform that action at this time.
0 commit comments